[erlang-questions] Small and large (>=64B) binaries? How do they differ?

Dmytro Lytovchenko dmytro.lytovchenko@REDACTED
Wed Sep 20 09:40:07 CEST 2017


>From what I remember (some people who recently have worked with binaries
might know much more)

Binaries in binary heap (large bins) have own structure, i think the master
storage structure is called Binary. This is confusing even to me so have a
spoon of salt with this advice :)

https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_binary.h
https://github.com/erlang/otp/blob/master/erts/emulator/beam/binary.c

Binaries stored outside processes (proc-bins ProcBin), smaller than 64b
(proc-bins, structure ErlHeapBin i think) and sub-bins (ErlSubBin) have own
tag bit combinations on the process heap. So the GC and VM always know what
they have found. They might share part of C structure pointing to the
external binary, you can observe it as a macro included in the respective
structures, think is called ErtsMagicBinary. Macros is_not_binary, binary_size,
binary_bytes and ERTS_GET_REAL_BIN might become useful.

Also ref-bins all contain 'next' pointer, as a part of long linked list
which begins somewhere in process header (one such list belongs to every
process) and during GC this list is traversed to find out which ref-bins
are about to die and refcount is decremented.

2017-09-20 6:08 GMT+02:00 Frank Muller <frank.muller.erl@REDACTED>:

> Hi Dmytro,
>
> Thanks for the hint. I found a lot of references to these keywords ... bit
> lost.
>
> How about the rest of the questions?
>
> /Frank
>
> Tue. Sept. 19 2017 à 22:13, Dmytro Lytovchenko <
> dmytro.lytovchenko@REDACTED> wrote :
>
>> Look for binary, procbin, refbin (probably), and sub binary. Use this as
>> keywords
>>
>> On 19 Sep 2017 21:50, "Frank Muller" <frank.muller.erl@REDACTED> wrote:
>>
>>> Hi guys
>>>
>>> Newbie here…
>>>
>>> Can someone point me please to the C data structure representing small
>>> and large binaries inside the VM?
>>> Do they’ve the same C representation (or not)?
>>> How the VM distinguishes between them internally?
>>>
>>> Thank you.
>>> /Frank
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170920/402c9ca9/attachment.htm>


More information about the erlang-questions mailing list