Internal binary representation

Bjorn Gustavsson bjorn@REDACTED
Sat Mar 4 22:02:09 CET 2000


James Hague <jamesh@REDACTED> writes:

> 
> I've read "Protocol Programming in Erlang Using Binaries," the experimental
> prototype for Erlang's upcoming enhancements to binaries.  In this doc,
> there's an explanation of how binaries are represented internally.  My
> question:  Is this similar to how binaries are currently implemented or
> simply how the prototype worked?

The current implementation (R6B) has only reference-counted binaries,
not the other binaries. We plan to add on-heap binaries and sub-binaries (called
tail-binaries in the protoype) in R7. The segmented binaries we find far
too complicated.

> 
> Mostly, I'm curious how expensive split_binary is.  I know it returns two
> new binaries in addition to the original, but is that done on a logical
> level or does it copy the data?

There is no copying of the binary data itself, but for each
split_binary two instances of an internal structure is built and linked
into a linked list. There will be a slight cost at garbage-collection time
to traverse that list.

/Bjorn

-- 
Björn Gustavsson            Ericsson Utvecklings AB
bjorn@REDACTED      ÄT2/UAB/F/P
			    BOX 1505
			    125 25 Älvsjö



More information about the erlang-questions mailing list