<div dir="ltr">Hello guys,<br><br>While investigating some benchmarks with zlib on erlang I suspected that the elrang driver might be too slow. <br>Initially I wrote a small c++ app linking with zlib doing almost the same stuff like my erlang testing script and I found a big gap in performance between them.<br>Initial thought was that the difference might come from the overhead added by erlang itself. (converting from elrang terms into c++ data and vice versa)<br><br>Then I started creating my own nif library for zlib and I found that comparing with erlang driver it's around 30 % faster for doing the same job.<br>After other investigations on zlib I found some interesting articles regarding intel and cloudflare patches and also zlibng that performs much better than <br>the original zlib. After I linked my NIF with this zlib libraries I got a gain of around 69 % compared with erlang driver. <br><br>The testing script is here: <a href="https://github.com/silviucpp/ezlib/blob/master/testing/benchmark.erl">https://github.com/silviucpp/ezlib/blob/master/testing/benchmark.erl</a><br><br>Basically reads a file line by line and compress it N times.<br><br>For example: <br><br>    benchmark:run(ezlib,"file path here", 200, 6, 10, 1). <br>    benchmark:run(erlang,"file path here", 200, 6, 10, 1).<br><br>This is compressing the file 200 times with a compression level of 6 window size 10 and memory level 1. First one using my library second one using erlang driver.<br><br>Some benchmark results you can see on the <a href="https://github.com/silviucpp/ezlib">https://github.com/silviucpp/ezlib</a><br><br>I can understand that the erlang driver api is generic and allows you to customize a lot if things and mine it's not and it's built <br>around my need to use it with ejabberd but still I'm almost sure if I change the interface the performance difference will be the same. <br><br>Maybe my benchmark is not realistic or I'm missing something. <br>Feedback it's welcome.<br><br>Silviu<br> <br></div>