<div dir="ltr">Hi Michael,<div><br></div><div>With the module `msacc` you can get more info about what the dirty scheduler is busy with. For example it can do garbage collection too.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 19, 2018 at 5:19 PM, Michaël COQUARD <span dir="ltr"><<a href="mailto:michael.coquard@ac-nancy-metz.fr" target="_blank">michael.coquard@ac-nancy-metz.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I try to understand how the processes are scheduled on the dirty schedulers.<br>
<br>
As I understand, the dirty schedulers are meant to execute uninterruptible native code to avoid blocking the standard schedulers (and other Erlang processes) for a long time.<br>
<br>
I noticed the majority of all memory allocations are scheduled on the dirty schedulers: mmap(), munmap() and mremap() calls from the mseg_alloc and sys_alloc<br>
<br>
Now, consider the following code:<br>
-module(foo).<br>
-compile([export_all,nowarn_ex<wbr>port_all]).<br>
<br>
loop_reverse_erl() -><br>
    L = lists:seq(1,1000000),<br>
    loop_reverse_erl(L).<br>
<br>
loop_reverse_erl(L) -><br>
    my_reverse(L,[]),<br>
    loop_reverse_erl(L).<br>
<br>
% vanilla reverse written in pure Erlang from efficiency_guide.erl<br>
my_reverse([H|T], Acc) -> my_reverse(T, [H|Acc]);<br>
my_reverse([], Acc) -> Acc.<br>
<br>
When I launch the loop (foo:loop_reverse_erl().) from the shell, I see an activity on one of a dirty scheduler thread (with top -H -p <pid of beam.smp>)<br>
<br>
The dirty scheduler doesn't do anything on a simple infinite loop like this<br>
loop_reverse_erl(L) -><br>
    loop_reverse_erl(L).<br>
<br>
I was expecting only native functions (BIFs / NIFs) are executed on the dirty schedulers.<br>
<br>
Is it the expected behavior ? If yes, which conditions trigger the choice of the "dirty" or "normal" scheduler ?<br>
<br>
OS: Linux RHEL 7<br>
Erlang version: OTP/21 erts-10.0 (same on OTP/20)<br>
<br>
Michael<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
</blockquote></div><br></div>