[erlang-questions] Size of a map key in words

Lukas Larsson lukas@REDACTED
Fri Jun 30 10:13:54 CEST 2017


On Fri, Jun 30, 2017 at 4:59 AM, Michael Truog <mjtruog@REDACTED> wrote:

> On 06/29/2017 06:13 PM, Richard A. O'Keefe wrote:
>
>> On 30/06/2017, at 12:23 PM, Michael Truog <mjtruog@REDACTED> wrote:
>>>
>>>>
>>>> http://erlang.org/doc/efficiency_guide/advanced.html#id68923 has the
>>> memory information and https://github.com/okeuday/erlang_term shows how
>>> to get this size during runtime.
>>>
>> Those two disagree.  For example, erlang_term says
>> Small Map (N =< 32):
>>    4 words + 2 words per key/value pair + the size of each pair
>> whereas advanced.html says
>> Small Map
>>    5 words + the size of all keys and values.
>>
>> The latter just *has* to be wrong, the former is at least believable.
>>
>> The erlang_term README information is based on an older version of the
> Erlang Efficiency guide html docs and the newer content is different.  It
> is possible an error was inserted into the new html docs, but it would be
> best for the Erlang/OTP team to check this.
>
>
The latter is the correct value. The documentation for both small and large
map sizes was incorrect and fixed in OTP-19.3 (I think).

Small map size = boxed ptr + header + size + key ptr + key header = 5 words.

The old incorrect version did not count the boxed ptr as part of the term
size.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170630/0d912a47/attachment.htm>


More information about the erlang-questions mailing list