couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: chunked response and couch_doc_open
Date Fri, 23 Oct 2009 19:43:43 GMT
On Fri, Oct 23, 2009 at 3:34 PM, Zoltan Lajos Kis <kiszl@tmit.bme.hu> wrote:
> Paul Davis wrote:
>>>
>>> Hello,
>>>
>>> You can use the erts_debug:size(Term) and erts_debug:flat_size(Term)
>>> functions. They are somewhat
>>> documented here:
>>> http://www.erlang.org/doc/efficiency_guide/processes.html .
>>> Note that the returned
>>> value is in words and not bytes (see erlang:system_info(wordsize). ).
>>>
>>> Zoltan.
>>>
>>>
>>
>> Zachary,
>>
>> Most interesting, but I'm a bit confused by what its reporting:
>>
>> 1> erts_debug:size("stuff") * erlang:system_info(wordsize).
>> 80
>> 2> size(term_to_binary("stuff")).
>> 9
>>
>> Is it really using 80 bytes internally to represent that?
>>
>> Paul Davis
>>
>
> Hello.
>
> "stuff" is a linked list ( [115,116,117,102,102] ) built of cons cells,
> each consisting of one handler (pointer) to the current item, and one to the
> next cons cell.
> That is ten pointers each taking a word, 10 x 8 = 80 bytes in a 64-bit OS.

Oh! Totally didn't realize that was counting the size of the internals
like that, but makes obvious sense now that you point it out.

> Converted to binary it is stored as you would expect it to be (in 5 bytes),
> plus you get some
> overhead (version info, metadata, list length, whatever) pumping it up to 9
> bytes.
>
> Btw I believe the erts_debug:size() functions only deal with the size of the
> term structure, so they
> will behave odd if used with binaries.
>
> Zoltan (who is definitely not Zolton ;))

Whoops! Must've transposed that in my head.

Paul Davis

Mime
View raw message