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 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?

darnahsan

darnahsan

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

thiagomajesk

thiagomajesk

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

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement