There is no other locking for code loading than blocking. This is an optimization of course since locking mechanism overhead is removed from the equation. Code loading is not used all that often in the normal cases besides startups and upgrades.<div>
<br></div><div>That being said, there are plans to remove this "stop-the-world" strategy since it is blocking other strategies and optimizations. Also, we are well aware of that blocking does degrade performance when loading new modules and does not agree with our concurrency policy.</div>
<div><br></div><div>I think we can lessen the time blocked in the current implementation but the blocking strategy should (and probably will) be removed. Nothing planned as of yet though.</div><div><br></div><div>Regards,</div>
<div>Björn-Egil<br><br><div class="gmail_quote">2011/11/5 Bob Ippolito <span dir="ltr"><<a href="mailto:bob@redivi.com">bob@redivi.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
We've found a bottleneck in some of our systems, when we load in large<br>
new modules there is a noticeable pause (1+ seconds) that blocks all<br>
of the schedulers. It looks like this is because the<br>
erlang:load_binary/2 BIF blocks SMP before it does anything at all.<br>
<br>
It would be a big win for us if more of this happened without blocking<br>
the VM, there's a lot of busy work in loading a module that shouldn't<br>
need any locking. For example, decompressing and decoding the literal<br>
table is probably where our code spends almost all of its time.<br>
<br>
There aren't a lot of comments for why it needs to lock the VM,<br>
especially for the whole of load_binary. Are there any hidden gotchas<br>
in here that I should know about before giving it a try? I'm unable to<br>
find much where the block is actually necessary, but I am not very<br>
familiar with the BEAM implementation yet.<br>
<br>
I expect that the erts_export_consolidate, insert_new_code and<br>
final_touch are really the only things that need so much<br>
serialization, and maybe the set_default_trace_pattern… is there<br>
anything big that I'm missing? It seems that breaking up<br>
erts_load_module into two functions (one to do all the decoding<br>
without the erts_smp_block_system(0), and the other to do the<br>
integration work with the block) would be straightforward.<br>
<br>
-bob<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" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>