chungwong

chungwong

Elixir NIF performance compared to native C++

I have a library which is written in C++, and I wrote a NIF “bridge” for it.

When I bench marked the library in C++, it had ~400-600 ips.

Then I bench marked it in Elixir, the result surprised me and it reached minimum 4k ips.

I couldn’t believe my eyes so I spinning a drogon http server to battle with Phoenix.

And the results from the two stay pretty much the same ~400 rps vs ~3k-6k rps.

How come a native C++ call is MUCH slower than the one from Elixir NIF?

Most Liked

rjk

rjk

Are you able to share the code? It would be easier this way to say something sensible about it.
But from my own experience it’s quite difficult to measure between 2 platforms in a correct way.
(I’m using rustler myself and performance seems to be faster on the 100% rust side, I have never seen the elixir/NIF part being faster because of the (sometimes little) overhead crossing the NIF bridge)

yurko

yurko

Could be that your benchmarks are parallelized for BEAM but not when testing native C++?

hauleth

hauleth

As @rjk and @yurko said, it can depend on many things. If you could provide MCVE so we could check this out, then maybe we could give you more correct answer.

Last Post!

hauleth

hauleth

20’000 iterations in 20 seconds mean less throughput than 2’000 iterations in 1 second. And from what I see Google Bench gives you amount of iterations, not IPS.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

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
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
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
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement