<div dir="ltr"><div>Yes because I'm compressing small chunks that anyway takes less than 1-2 ms<br><br></div>Silviu<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 1:02 PM, Sergej Jurečko <span dir="ltr"><<a href="mailto:sergej.jurecko@gmail.com" target="_blank">sergej.jurecko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>If you care about compression speed zlib is a terrible choice anyway. Also in your NIF you seem to be doing the entire compression on a scheduler thread all in one go. This is very bad. NIF calls should not take more than ~1ms.</div><div><br></div><div>Sergej</div><div><div><br><div><blockquote type="cite"><div><div class="h5"><div>On 09 Mar 2016, at 11:54, Caragea Silviu <<a href="mailto:silviu.cpp@gmail.com" target="_blank">silviu.cpp@gmail.com</a>> wrote:</div><br></div></div><div><div><div class="h5"><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" target="_blank">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" target="_blank">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></div></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div>