incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zoltan Lajos Kis <ki...@tmit.bme.hu>
Subject Re: chunked response and couch_doc_open
Date Fri, 23 Oct 2009 19:34:23 GMT
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.

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 ;))


Mime
View raw message