<div dir="ltr">Hello,<div><br></div><div>On Wed, May 14, 2014 at 10:26 PM, Joe Armstrong <span dir="ltr"><<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" 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">
<div dir="ltr"><div><br></div><div>I'd like a have a rough idea of the average number of memory fetches and</div><div>stores per Beam instruction and per Erlang reduction.</div><div><br></div></div></blockquote></div>
<div><br></div><div>I recently did some digging into optimizing the code for the emulator and created a tool that extracts the c-code and assembler output for each instruction in beam. I did the checks for both PowerPC[1] and x86[2]. From this you should be able to parse out how many fetches and stores each instruction does. I don't know how many instructions there normally is per function, but if you just take some random code and use erts_debug:df(Module) you will get a file with one instruction per line and then you can extrapolate. </div>
<div><br></div><div>I'm not sure what kind of performance indicator this will be though as you have to know the cache hit rate and memory latency as well to judge how long time each instruction takes. Also normally I've found that an Erlang application spends about 50% of it's time executing code outside the emulator loop (ets, gc, bifs etc).</div>
<div><br></div><div>Lukas<br><div class="gmail_extra"><br></div><div class="gmail_extra">   [1]: <a href="https://dl.dropboxusercontent.com/u/6250179/asm_comparison_ppc.html">https://dl.dropboxusercontent.com/u/6250179/asm_comparison_ppc.html</a> (download file for css to work, the new part is after some optimizations I did for ppc only)</div>
<div class="gmail_extra">   [2]: <a href="https://dl.dropboxusercontent.com/u/6250179/asm_x86.html">https://dl.dropboxusercontent.com/u/6250179/asm_x86.html</a> (download file for css to work)<br><br><div class="gmail_quote">
<div> </div></div></div></div></div>