[erlang-questions] Trying to understand the performance impact of binary:split/3

Jay Nelson jay@REDACTED
Thu May 21 21:56:58 CEST 2015

Jose wrote:

> I wonder how fast it would be if binary:split/3 was written as a BIF.

I wrote a BIF in 2005 for manipulating binaries. It was documented in
an ICFP presentation and ACM paper. You can read about it, the
erlang code, and more importantly the actual BIF code at my website
http://duomark.com/erlang/index.html <http://duomark.com/erlang/index.html> listed under the title
“A Stream Library Using Erlang Binaries”. There are separate links
for the HTML Briefing and Code.

http://duomark.com/erlang/publications/acm2005.pdf <http://duomark.com/erlang/publications/acm2005.pdf>

From the abstract:

"The new BIFs are shown to improve performance as much as 250
times over native erlang functions. The reduction in memory usage
caused by the BIFs also allows successful processing in situations
that crashed the runtime as application functions."

There is a gzip tar file that you used to be able to overlay on R10B(!!)
to build the BIFs. But it is all contained in a single stream.c file and the
corresponding BIF table entries are in the other parts of the erts and
beam directories there, so it should be easy to adapt to the current
release you are working with. You should be able
to quickly get into the source and see if it meets any of your needs.
It will require some modification, and there are manual loop unrolling
and so forth that I did for performance, but as a rough quick test of
whether a BIF would be helpful this might be the quickest way to get

If you do achieve interesting results, be sure to add reduction count
bumping in the BIF. This code predates the option of doing that.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150521/e0bdd8c1/attachment.htm>

More information about the erlang-questions mailing list