<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby.git/test/ruby/test_optimization.rb, branch ruby_3_2</title>
<subtitle>github.com: ruby/ruby.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/'/>
<entry>
<title>Use omit instead of skip: test/ruby/**/*.rb</title>
<updated>2022-01-04T08:25:30+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2022-01-04T08:25:30+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=47bf64a26d3d95a312ea5cf5d94ee1d2104f5e26'/>
<id>47bf64a26d3d95a312ea5cf5d94ee1d2104f5e26</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Prepare for removing RubyVM::JIT (#5262)</title>
<updated>2021-12-14T07:07:46+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2021-12-14T07:07:46+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=1a63468831524f68e73cbb068071652c6486cfc6'/>
<id>1a63468831524f68e73cbb068071652c6486cfc6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize dynamic string interpolation for symbol/true/false/nil/0-9</title>
<updated>2021-11-18T23:10:20+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-11-18T23:10:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=b08dacfea39ad8da3f1fd7fdd0e4538cc892ec44'/>
<id>b08dacfea39ad8da3f1fd7fdd0e4538cc892ec44</id>
<content type='text'>
This provides a significant speedup for symbol, true, false,
nil, and 0-9, class/module, and a small speedup in most other cases.

Speedups (using included benchmarks):
:symbol        :: 60%
0-9            :: 50%
Class/Module   :: 50%
nil/true/false :: 20%
integer        :: 10%
[]             :: 10%
""             :: 3%

One reason this approach is faster is it reduces the number of
VM instructions for each interpolated value.

Initial idea, approach, and benchmarks from Eric Wong. I applied
the same approach against the master branch, updating it to handle
the significant internal changes since this was first proposed 4
years ago (such as CALL_INFO/CALL_CACHE -&gt; CALL_DATA). I also
expanded it to optimize true/false/nil/0-9/class/module, and added
handling of missing methods, refined methods, and RUBY_DEBUG.

This renames the tostring insn to anytostring, and adds an
objtostring insn that implements the optimization. This requires
making a few functions non-static, and adding some non-static
functions.

This disables 4 YJIT tests.  Those tests should be reenabled after
YJIT optimizes the new objtostring insn.

Implements [Feature #13715]

Co-authored-by: Eric Wong &lt;e@80x24.org&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;
Co-authored-by: Yusuke Endoh &lt;mame@ruby-lang.org&gt;
Co-authored-by: Koichi Sasada &lt;ko1@atdot.net&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This provides a significant speedup for symbol, true, false,
nil, and 0-9, class/module, and a small speedup in most other cases.

Speedups (using included benchmarks):
:symbol        :: 60%
0-9            :: 50%
Class/Module   :: 50%
nil/true/false :: 20%
integer        :: 10%
[]             :: 10%
""             :: 3%

One reason this approach is faster is it reduces the number of
VM instructions for each interpolated value.

Initial idea, approach, and benchmarks from Eric Wong. I applied
the same approach against the master branch, updating it to handle
the significant internal changes since this was first proposed 4
years ago (such as CALL_INFO/CALL_CACHE -&gt; CALL_DATA). I also
expanded it to optimize true/false/nil/0-9/class/module, and added
handling of missing methods, refined methods, and RUBY_DEBUG.

This renames the tostring insn to anytostring, and adds an
objtostring insn that implements the optimization. This requires
making a few functions non-static, and adding some non-static
functions.

This disables 4 YJIT tests.  Those tests should be reenabled after
YJIT optimizes the new objtostring insn.

Implements [Feature #13715]

Co-authored-by: Eric Wong &lt;e@80x24.org&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;
Co-authored-by: Yusuke Endoh &lt;mame@ruby-lang.org&gt;
Co-authored-by: Koichi Sasada &lt;ko1@atdot.net&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Make Array#min/max optimization respect refined methods</title>
<updated>2021-09-30T22:18:14+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-09-30T22:18:14+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=1f5f8a187adb746b01cc95c3f29a0a355f513374'/>
<id>1f5f8a187adb746b01cc95c3f29a0a355f513374</id>
<content type='text'>
Pass in ec to vm_opt_newarray_{max,min}. Avoids having to
call GET_EC inside the functions, for better performance.

While here, add a test for Array#min/max being redefined to
test_optimization.rb.

Fixes [Bug #18180]</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pass in ec to vm_opt_newarray_{max,min}. Avoids having to
call GET_EC inside the functions, for better performance.

While here, add a test for Array#min/max being redefined to
test_optimization.rb.

Fixes [Bug #18180]</pre>
</div>
</content>
</entry>
<entry>
<title>Fix warnings in test_optimization.rb</title>
<updated>2021-08-24T15:34:48+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-08-24T15:34:48+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=14a9c364f75a9729d5a49e1fbea08fec2f813bdd'/>
<id>14a9c364f75a9729d5a49e1fbea08fec2f813bdd</id>
<content type='text'>
These were introduced in the test for tracing optimized methods
added in 48c8df9e0eb295af06d593ce37ce1933c0ee1d90.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These were introduced in the test for tracing optimized methods
added in 48c8df9e0eb295af06d593ce37ce1933c0ee1d90.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow tracing of optimized methods</title>
<updated>2021-08-21T17:15:01+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-08-21T17:15:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=48c8df9e0eb295af06d593ce37ce1933c0ee1d90'/>
<id>48c8df9e0eb295af06d593ce37ce1933c0ee1d90</id>
<content type='text'>
This updates the trace instructions to directly dispatch to
opt_send_without_block.  So this should cause no slowdown in
non-trace mode.

To enable the tracing of the optimized methods, RUBY_EVENT_C_CALL
and RUBY_EVENT_C_RETURN are added as events to the specialized
instructions.

Fixes [Bug #14870]

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This updates the trace instructions to directly dispatch to
opt_send_without_block.  So this should cause no slowdown in
non-trace mode.

To enable the tracing of the optimized methods, RUBY_EVENT_C_CALL
and RUBY_EVENT_C_RETURN are added as events to the specialized
instructions.

Fixes [Bug #14870]

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Rename RubyVM::MJIT to RubyVM::JIT</title>
<updated>2021-01-14T06:46:51+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2021-01-14T06:36:45+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=e1fee7f949cb6719122672fa1081c60984a5339f'/>
<id>e1fee7f949cb6719122672fa1081c60984a5339f</id>
<content type='text'>
because the name "MJIT" is an internal code name, it's inconsistent with
--jit while they are related to each other, and I want to discourage future
JIT implementation-specific (e.g. MJIT-specific) APIs by this rename.

[Feature #17490]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
because the name "MJIT" is an internal code name, it's inconsistent with
--jit while they are related to each other, and I want to discourage future
JIT implementation-specific (e.g. MJIT-specific) APIs by this rename.

[Feature #17490]
</pre>
</div>
</content>
</entry>
<entry>
<title>Guard all accesses to RubyVM::MJIT with defined?(RubyVM::MJIT) &amp;&amp;</title>
<updated>2020-12-04T15:45:54+00:00</updated>
<author>
<name>Benoit Daloze</name>
<email>eregontp@gmail.com</email>
</author>
<published>2020-12-04T15:40:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=b4ec4a41c24105efbb43f9b70ca7f36d22f98294'/>
<id>b4ec4a41c24105efbb43f9b70ca7f36d22f98294</id>
<content type='text'>
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
</pre>
</div>
</content>
</entry>
<entry>
<title>disable GC on a test</title>
<updated>2020-06-09T06:52:25+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2020-06-09T06:52:25+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=195075e8f5f2220a0a1f00f5cfd2ad98681e71d5'/>
<id>195075e8f5f2220a0a1f00f5cfd2ad98681e71d5</id>
<content type='text'>
CI fails with GC while `foo{}`, so that disable GC for this script.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
CI fails with GC while `foo{}`, so that disable GC for this script.
</pre>
</div>
</content>
</entry>
<entry>
<title>test/ruby/test_optimization.rb: Proc creation test should count :T_DATA</title>
<updated>2020-05-21T04:27:26+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2020-05-21T04:16:42+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=3eb3f7bb8c3da4d3e71246ad011c580b6ad68d78'/>
<id>3eb3f7bb8c3da4d3e71246ad011c580b6ad68d78</id>
<content type='text'>
instead of :TOTAL of ObjectSpace.count_objects.

This test had failed very occasionally:

https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200521T033004Z.fail.html.gz
```
  1) Failure:
TestRubyOptimization#test_block_parameter_should_not_create_objects [/home/chkbuild/chkbuild/tmp/build/20200521T033004Z/ruby/test/ruby/test_optimization.rb:713]:
&lt;0&gt; expected but was
&lt;407&gt;.
```

This test of lazy proc creation checks if no object is created during a
method call.  However, calling a method itself increases the count of
objects because method cache is now an object (T_MEMO).
The reason why this test rarely fails is because the test was buggy; it
checked the count of :TOTAL, but :TOTAL count changes only when the GC
heap is expanded.  Creating one object rarely causes heap expansion.
The test must have checked not only :TOTAL but also the count of :FREE.

Instead, this change more directly checks :T_DATA.  Note that a Proc
object is T_DATA.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
instead of :TOTAL of ObjectSpace.count_objects.

This test had failed very occasionally:

https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200521T033004Z.fail.html.gz
```
  1) Failure:
TestRubyOptimization#test_block_parameter_should_not_create_objects [/home/chkbuild/chkbuild/tmp/build/20200521T033004Z/ruby/test/ruby/test_optimization.rb:713]:
&lt;0&gt; expected but was
&lt;407&gt;.
```

This test of lazy proc creation checks if no object is created during a
method call.  However, calling a method itself increases the count of
objects because method cache is now an object (T_MEMO).
The reason why this test rarely fails is because the test was buggy; it
checked the count of :TOTAL, but :TOTAL count changes only when the GC
heap is expanded.  Creating one object rarely causes heap expansion.
The test must have checked not only :TOTAL but also the count of :FREE.

Instead, this change more directly checks :T_DATA.  Note that a Proc
object is T_DATA.
</pre>
</div>
</content>
</entry>
</feed>
