<div dir="ltr">Hello Sergei,<br><div><br>Your diagnostic does match what John Högberg mentioned in Erlanger Slack (#general channel) a few days ago - namely, that recent versions of OTP do much more aggressive optimizations.</div><div><br>On the bright side, it looks like OTP 24 will likely compile stuff faster - without necessarily compromising on said optimizations.</div><div><br></div><div>Cheers,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 29 Jul 2020 at 11:24, Сергей Прохоров <<a href="mailto:seriy.pr@gmail.com">seriy.pr@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">erlc has an option to measure how much time each compilation step takes: `erlc +time <erl file>`.<div><br></div><div>I tried it with your example:</div><div><br></div><div>OTP-23</div><div>```</div><div><font face="monospace">time erlc +time test_pb.erl<br></font></div><div><font face="monospace">Compiling "test_pb"<br> remove_file          :    0.000 s    3.3 kB<br> parse_module          :    0.577 s  14389.4 kB<br><..></font></div><div><font face="monospace"> core              :    0.660 s  110867.4 kB<br> core_old_inliner        :    0.439 s  130500.1 kB<br> sys_core_fold         :    0.707 s  95544.3 kB<br><..></font></div><div><font face="monospace"> v3_kernel           :    0.592 s  85036.7 kB<br><..></font></div><div><font face="monospace"> beam_ssa_bsm          :    1.241 s  52211.4 kB<br>  %% Sub passes of beam_ssa_bsm from slowest to fastest:<br>  combine_matches       :    0.458 s  37 %<br><..></font></div><div><font face="monospace"> beam_ssa_funs         :    0.053 s  52211.4 kB<br> beam_ssa_opt          :   11.192 s  41673.2 kB<br>  %% Sub passes of beam_ssa_opt from slowest to fastest:<br>  ssa_opt_type_start     :    5.128 s  47 %<br>  ssa_opt_live        :    1.892 s  17 %<br>  ssa_opt_type_continue    :    1.667 s  15 %<br>  ssa_opt_dead        :    0.919 s  8 %<br>  ssa_opt_sink        :    0.506 s  5 %<br><..><br> beam_ssa_recv         :    0.050 s  41673.2 kB<br> beam_ssa_pre_codegen      :    1.913 s  49962.4 kB<br>  %% Sub passes of beam_ssa_pre_codegen from slowest to fastest:<br>  live_intervals       :    0.468 s  25 %<br>  linear_scan         :    0.250 s  13 %<br><..></font></div><div><font face="monospace"> beam_ssa_codegen        :    0.797 s  21962.5 kB<br> beam_validator_strong     :    0.603 s  21962.5 kB</font></div><div><font face="monospace"><..><br> save_binary          :    0.001 s    55.7 kB<br>erlc +time test_pb.erl  21.69s user 1.67s system 102% cpu 22.685 total</font><br></div><div>```</div><div><br></div><div>and, eg, OTP-21:</div><div>```</div><div><font face="monospace">time erlc +time test_pb.erl<br>Compiling "test_pb"<br> remove_file          :    0.000 s    3.3 kB<br> parse_module          :    0.588 s  14389.4 kB<br><..></font></div><div><font face="monospace"> core              :    0.632 s  110405.3 kB<br> core_old_inliner        :    0.531 s  130242.5 kB<br> sys_core_fold         :    0.894 s  95317.8 kB<br><..></font></div><div><font face="monospace"> v3_kernel           :    0.721 s  114068.9 kB<br> v3_codegen           :    0.627 s  26703.4 kB<br><..></font></div><div><font face="monospace"> save_binary          :    0.000 s    55.7 kB<br>erlc +time test_pb.erl  8.39s user 0.48s system 111% cpu 7.980 total</font><br></div><div>```</div><div><br></div><div>OTP-22:</div><div>```</div><div><font face="monospace">Compiling "test_pb"<br> remove_file          :    0.000 s    3.3 kB<br> parse_module          :    0.578 s  14389.4 kB<br><..></font></div><div><font face="monospace"> core              :    0.546 s  110405.3 kB<br> core_old_inliner        :    0.449 s  129401.0 kB<br> sys_core_fold         :    0.768 s  95241.3 kB<br><..></font></div><div><font face="monospace"> v3_kernel           :    0.681 s  113407.6 kB<br> beam_kernel_to_ssa       :    0.225 s  45635.5 kB<br> beam_ssa_share         :    0.081 s  45375.4 kB<br> beam_ssa_bsm          :    1.157 s  49943.7 kB<br>  %% Sub passes of beam_ssa_bsm from slowest to fastest:<br>  combine_matches       :    0.404 s  35 %<br><..></font></div><div><font face="monospace"> beam_ssa_funs         :    0.049 s  49436.8 kB<br> beam_ssa_opt          :    4.938 s  44202.7 kB<br>  %% Sub passes of beam_ssa_opt from slowest to fastest:<br>  ssa_opt_live        :    1.259 s  27 %<br>  ssa_opt_type_continue    :    1.159 s  24 %<br>  ssa_opt_dead        :    0.879 s  19 %<br>  ssa_opt_type_start     :    0.649 s  14 %<br><..></font></div><div><font face="monospace"> beam_ssa_recv         :    0.049 s  44202.7 kB<br> beam_ssa_pre_codegen      :    2.485 s  59314.1 kB<br>  %% Sub passes of beam_ssa_pre_codegen from slowest to fastest:<br>  live_intervals       :    0.710 s  29 %<br><..></font></div><div><font face="monospace"> beam_ssa_codegen        :    0.989 s  23579.8 kB<br><..></font></div><div><font face="monospace"> save_binary          :    0.001 s    55.7 kB<br>erlc +time test_pb.erl  15.85s user 1.32s system 106% cpu 16.183 total</font><br></div><div>```</div><div><br></div><div>So it seems there were a lot of `beam ssa` optimization passes aded and some of them are quite slow on large files.</div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>