<head></head><body><!-- <signature> -->Hello,<!-- </signature> --><div><!-- <signature> --><br><!-- </signature> --></div><div><!-- <signature> -->It took me some time to finally get around to looking again at this.<!-- </signature> --></div><div><!-- <signature> --><br><!-- </signature> --></div><div><!-- <signature> -->Running the instrument module turned out to be very helpful, thank you Lukas for this suggestion.<!-- </signature> --></div><div><!-- <signature> --><br><!-- </signature> --></div><div><!-- <signature> -->I got very high usage for drv_tab, fd_tab and port_tab:<!-- </signature> --></div><div><!-- <signature> -->{drv_tab,[{sizes,50331648,50331648,50331648},<br> {blocks,1,1,1}]},<br> {fd_tab,[{sizes,33554432,33554432,33554432},{blocks,1,1,1}]},<br> {port_tab,[{sizes,12582975,12582975,12582975},<br> {blocks,1,1,1}]}<br><!-- </signature> --></div><div><!-- <signature> --><br><!-- </signature> --></div><div><!-- <signature> -->Running docker with decreased ulimit via the --ulimit nofile=1024:1024 flag seems to fix this issue.<!-- </signature> --></div><div><!-- <signature> -->There is still increased binary usage, but it's not in any way as severe as this was.<!-- </signature> --></div><div><!-- <signature> --><br><!-- </signature> --></div><div><!-- <signature> -->Thank you for your help,<!-- </signature> --></div><div><!-- <signature> -->Michał.<!-- </signature> --></div><div class="gmail_quote">
On Mar 29 2016, at 6:44 pm, Lukas Larsson <lukas@erlang.org> wrote:
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">Hello,<div><br></div><div>You want to start the emulator with the "+Mim true +Mis true" flags and then use instrument (<a href="http://erlang.org/doc/man/instrument.html">http://erlang.org/doc/man/instrument.html</a>) to inspect what is going on. The most interesting for you should be something like:</div><div><br></div><div>lists:reverse(lists:keysort(2,instrument:memory_status(types))).</div><div><br></div><div>For example:</div><div><br></div><div><div>erl +Mis true +Mim true</div><div>Erlang/OTP 19 [DEVELOPMENT] [erts-8.0] [source-9946a17] [64-bit] [smp:16:16] [async-threads:10] [hipe] [kernel-poll:false]</div><div><div>1> lists:reverse(lists:keysort(2,instrument:memory_status(types))).</div><div>[{timer_wheel,[{sizes,8391792,8391792,8391792},</div><div> {blocks,16,16,16}]},</div><div> {code,[{sizes,3463220,3463220,3469945},{blocks,84,84,84}]},</div><div> {proc_tab,[{sizes,3145791,3145791,3145791},{blocks,1,1,1}]},</div><div> {heap,[{sizes,1882920,1932208,3456120},{blocks,26,28,28}]},</div><div> {pre_alloc_data,[{sizes,1032303,1032303,1032303},</div><div> {blocks,17,17,17}]},</div><div> {port_tab,[{sizes,786495,786495,786495},{blocks,1,1,1}]},</div><div> {old_heap,[{sizes,679872,682880,2941656},{blocks,10,11,11}]},</div><div> {scheduler_data,[{sizes,673141,673141,673141},</div><div> {blocks,3,3,3}]},</div><div> {export_entry,[{sizes,462528,462528,462528},</div><div> {blocks,2628,2628,2628}]},</div><div> {literal,[{sizes,379648,379648,379648},{blocks,84,84,84}]},</div><div> {ethread_long_lived,[{sizes,326016,326016,326016},</div><div> {blocks,283,283,283}]},</div><div> {atom_entry,[{sizes,304840,304840,304840},</div><div> {blocks,7621,7621,7621}]},</div><div> {beam_register,[{sizes,264544,264544,264544},</div><div> {blocks,32,32,32}]},</div><div> {export_tab,[{sizes,162888,162888,162888},</div><div> {blocks,15,15,15}]},</div><div> {hipe_data,[{sizes,148464,148464,148464},{blocks,18,18,18}]},</div><div> {ethread_standard,[{sizes,133487,133487,133487},</div><div> {blocks,6,6,6}]},</div><div> {db_term,[{sizes,119568,119568,119568},</div><div> {blocks,388,388,388}]},</div><div> {atom_tab,[{sizes,112232,112232,121472},{blocks,10,10,10}]},</div><div> {atom_text,[{sizes,98328,98328,98328},{blocks,3,3,3}]},</div><div> {db_tabs,[{sizes,82023,82023,82023},{blocks,3,3,3}]},</div><div> {drv_internal,[{sizes,79352,79352,79608},{blocks,4,4,19}]},</div><div> {db_segment,[{sizes,51744,51744,53824},{blocks,19,19,...}]},</div><div> {fun_entry,[{sizes,51568,51568,...},{blocks,586,...}]},</div><div> {drv_binary,[{sizes,47774,...},{blocks,...}]},</div><div> {driver_event_state,[{sizes,...},{...}]},</div><div> {module_tab,[{...}|...]},</div><div> {module_entry,[...]},</div><div> {proc,...},</div><div> {...}|...]</div></div><div><br></div><div>So in the above we can see that the timer wheel structures take the most memory and then code, proc tab etc etc.</div><div><br></div><div>Lukas</div><div><br><div>On Tue, Mar 29, 2016 at 2:01 PM, Michał Muskała <span dir="ltr"><<a href="mailto:michal@muskala.eu" target="_blank">michal@muskala.eu</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello everybody,<br>
<br>
This is a followup from the elixir mailing list:<br>
<a href="https://groups.google.com/forum/#!msg/elixir-lang-talk/TqIcSVkHBxs/N1nWRWW9BwAJ" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!msg/elixir-lang-talk/TqIcSVkHBxs/N1nWRWW9BwAJ</a><br>
There were several issues involved in that particular problem, but one<br>
of them might be of interest to the people here as well, as it's<br>
generally erlang-related rather than tied to elixir or any package in<br>
particular.<br>
<br>
The issue comes down to unusually high memory consumption for erlang,<br>
specifically the system part from erlang:memory/0. The output below<br>
shows values when running outside docker and inside:<br>
<br>
Outside docker:<br>
erl -eval 'io:format("~w~n", [erlang:memory()]), init:stop().' -noshell<br>
[{total,15182640},{processes,3799768},{processes_used,3797720},{system,11382872},{atom,194289},{atom_used,169621},{binary,78344},{code,3868184},{ets,229416}]<br>
<br>
Inside docker's official erlang image (debian based)<br>
docker run --rm -it erlang:18-slim erl -eval 'io:format("~w~n",<br>
[erlang:memory()]), init:stop().' -noshell<br>
[{total,111303160},{processes,3799768},{processes_used,3797720},{system,107503392},{atom,194289},{atom_used,169584},{binary,595608},{code,3860673},{ets,239464}]<br>
<br>
Inside minimal alpine linux erlang image<br>
docker run --rm -it msaraiva/erlang erl -eval 'io:format("~w~n",<br>
[erlang:memory()]), init:stop().' -noshell<br>
[{total,111432888},{processes,3748312},{processes_used,3746312},{system,107684576},{atom,194289},{atom_used,169869},{binary,596568},{code,3847723},{ets,185296}]<br>
<br>
As you can see all the values except for system are very similar, with<br>
system being almost 10x as large. The issue is also consistent across<br>
different images. While outside docker a simple shell uses around<br>
15MB, inside docker it grows to 80MB.<br>
I tried to investigate the issue further using recon, and it looks<br>
like the excessive memory is allocated with ll_alloc, although I have<br>
to admit I'm out of my depth here.<br>
<br>
I'll be thankful for any help or indications where I could dig deeper.<br>
<br>
Michał.<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div></div></div>
</blockquote>
</div></body>