https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-11-14T09:08:47ZRuby Issue Tracking SystemRuby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=677962017-11-14T09:08:47Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><pre><code> user system total real
trace off 9.090678 0.000000 9.090678 ( 9.083007)
trace on 108.217320 0.005524 108.222844 (108.201941)
user system total real
trace off 6.647247 0.000000 6.647247 ( 6.641530)
trace on 93.405389 0.000000 93.405389 ( 93.404864)
</code></pre>
<p>\o/</p> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=677972017-11-14T10:11:05Zko1 (Koichi Sasada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/67797/diff?detail_id=46803">diff</a>)</li></ul> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=677982017-11-14T11:44:05Zko1 (Koichi Sasada)
<ul></ul><p>Here is a result of benchmark result with</p>
<pre><code>ruby ~/ruby/src/trunk/benchmark/driver.rb -e ruby_2_4::~/ruby/install/ruby_2_4/bin/ruby -e trunk_oct::~/ruby/install/trunk_r60079/bin/ruby -e trunk::~/ruby/install/trunk/bin/ruby -e modified::~/ruby/install/gitruby/bin/ruby -v -r 5
</code></pre>
<p><a href="https://gist.github.com/anonymous/64b7e73e5972befc33a9acde09612f90" class="external">https://gist.github.com/anonymous/64b7e73e5972befc33a9acde09612f90</a></p> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=678002017-11-14T12:58:47Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r60763.</p>
<hr>
<p>remove <code>trace</code> instruction. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Remove `trace` instructions (Closed)" href="https://bugs.ruby-lang.org/issues/14104">#14104</a>]</p>
<ul>
<li>
<p>tool/instruction.rb: create <code>trace_</code> prefix instructions.</p>
</li>
<li>
<p>compile.c (ADD_TRACE): do not add <code>trace</code> instructions but add<br>
TRACE link elements. TRACE elements will be unified with a next<br>
instruction as instruction information.</p>
</li>
<li>
<p>vm_trace.c (update_global_event_hook): modify all ISeqs when<br>
hooks are enabled.</p>
</li>
<li>
<p>iseq.c (rb_iseq_trace_set): added to toggle <code>trace_</code> instructions.</p>
</li>
<li>
<p>vm_insnhelper.c (vm_trace): added.<br>
This function is a body of <code>trace_</code> prefix instructions.</p>
</li>
<li>
<p>vm_insnhelper.h (JUMP): save PC to a control frame.</p>
</li>
<li>
<p>insns.def (trace): removed.</p>
</li>
<li>
<p>vm_exec.h (INSN_ENTRY_SIG): add debug output (disabled).</p>
</li>
</ul> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=678032017-11-14T16:40:37Zvmakarov (Vladimir Makarov)
<ul></ul><p>ko1 (Koichi Sasada) wrote:</p>
<blockquote>
<a name="Abstract"></a>
<h1 >Abstract<a href="#Abstract" class="wiki-anchor">¶</a></h1>
<p>Remove <code>trace</code> instructions from bytecode and it will improve performance, 10% faster.<br>
Instead of <code>trace</code> instruction, we add event information for each instruction.<br>
In other words, we unified <code>trace</code> instructions with the following instructions.</p>
</blockquote>
<p>Hi, Koichi. I am very glad that you addressed this issue. The current implementation of tracing is just wasting CPU time. I thought about this too but my approach would be a different because I thought that I had to maintain the full compatibility of trace behaviour.</p>
<p>So I considered to remove and insert trace insns when the tracing is off or on. It requires to change branch offset, catch table offsets, and line tables. To speed up this, I would keep the log of pairs (<place in iseq code, catch table, or line table>, ) and log of pairs (, ).</p>
<p>I also thought that such general log mechanism would be useful in possible speculative iseq optimizations on MRI insns level.</p>
<p>But if the full trace behaviour compatibility is not so important, your solution is much much simpler and practically has the same code locality as you keep codes of trace and usual insns in disjoint parts of the interpreter switch-stmt.</p>
<p>I think rebuilding iseq is not a problem. Sorry if I missed the code change but I don't see a check of version of loaded iseq on compatibility. So what will happen if somebody tries to load the old iseq with trace insns into a new version of MRI?</p> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=679222017-11-27T05:59:05Zko1 (Koichi Sasada)
<ul></ul><p>vmakarov (Vladimir Makarov) wrote:</p>
<blockquote>
<p>So I considered to remove and insert trace insns when the tracing is off or on. It requires to change branch offset, catch table offsets, and line tables. To speed up this, I would keep the log of pairs (<place in iseq code, catch table, or line table>, ) and log of pairs (, ).</p>
<p>I also thought that such general log mechanism would be useful in possible speculative iseq optimizations on MRI insns level.</p>
</blockquote>
<p>I completely agree your approach is more compatible and flexible for other optimization techniques. But it is some tough work to implement it because PC info are located variety of places. I also believe (sometime) we need to implement similar technique you explained.</p>
<blockquote>
<p>But if the full trace behaviour compatibility is not so important, your solution is much much simpler and practically has the same code locality as you keep codes of trace and usual insns in disjoint parts of the interpreter switch-stmt.</p>
</blockquote>
<p>Yes, simplicity is the reason why I use this technique.<br>
Only few days I needed to make.</p>
<blockquote>
<p>I think rebuilding iseq is not a problem. Sorry if I missed the code change but I don't see a check of version of loaded iseq on compatibility. So what will happen if somebody tries to load the old iseq with trace insns into a new version of MRI?</p>
</blockquote>
<p>We don't guarantee the cross-version dump/load compatibility (this is why we embed version info into dumped results). So I believe there are no problem on this change.</p> Ruby master - Feature #14104: Remove `trace` instructionshttps://bugs.ruby-lang.org/issues/14104?journal_id=978902022-06-09T05:36:44Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-1 priority-4 priority-default" href="/issues/14582">Bug #14582</a>: Unable to use `method__entry` and `method_return` tracing probes since 2.5</i> added</li></ul>