thiagomajesk

thiagomajesk

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: Compliant elixir RSS 2.0 and Atom 1.0 parser · GitHub 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…)

Most Liked

kip

kip

ex_cldr Core Team

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?

gregvaughn

gregvaughn

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.

thiagomajesk

thiagomajesk

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?

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement