Any tips and tricks for speeding up Elixir code out there?

Hello everyone! I’ve been working on a hobby project recently and was trying to find content on how to make Elixir code more performant… I’ve been working on this RSS feed parser: GitHub - thiagomajesk/gluttony that is based on Saxy and was wondering how much faster I could make this code without recurring to external aid (without using NIFs). From the initial benchmarks that I did, the code is already very fast compared to other alternatives (mostly because of the difference in performance from the underlying parser). So, I basically want to see how much overhead I can take off of my custom processing logic to make it as fast as it can naturally be¹…

Do you guys have any tips, tricks, tools, or materials that would be interesting to share?

¹This is more of a learning experience that an actual necessity. I’m fairly happy with the current performance of the program but I think it would be interesting to have a little bit more knowledge on the subject if I happen to need some time in the future.

PS.: Any considerations on how the code is shaping up to be are welcome as well (I don’t know a lot of experienced people that work with Elixir to review this so…)


I have not personally dug into this library, but the Jason library was written with the intention of higher performance than other json parsing libraries at the time. I’m sure there’s great techniques to mine from that codebase, and it’s also a parser, so it’s conceptually similar to your RSS parser.

1 Like

Cool @gregvaughn! Even though I’m not trying to change the parser’s code, do you remember any particular scenario that caught your attention for me to look into?

1 Like

this is not available on hex, would you publishing it ?

1 Like

I intend to when it’s ready (you can get it from the repo if you want to try it out btw).

1 Like

The most common optimisation I’ve seen applied applications like parsing is to focus on sub binary optimisation. There erlang documentation has quite a good write up on this too.

The basic idea being to avoid copying binaries and to reuse references. Might not be applicable in your case since its likely Saxy is doing the raw parsing?