ruby-changes:51883
From: k0kubun <ko1@a...>
Date: Sun, 29 Jul 2018 11:05:16 +0900 (JST)
Subject: [ruby-changes:51883] k0kubun:r64097 (trunk): mjit.c: disable compaction on empty queue w/ --jit-wait
k0kubun 2018-07-29 11:05:08 +0900 (Sun, 29 Jul 2018) New Revision: 64097 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64097 Log: mjit.c: disable compaction on empty queue w/ --jit-wait When --jit-wait is specified, `unit_queue.length` is always 0 and it's not a good metric. Modified files: trunk/mjit.c trunk/test/ruby/test_jit.rb Index: test/ruby/test_jit.rb =================================================================== --- test/ruby/test_jit.rb (revision 64096) +++ test/ruby/test_jit.rb (revision 64097) @@ -9,7 +9,6 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L9 IGNORABLE_PATTERNS = [ /\ASuccessful MJIT finish\n\z/, - /\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods ->/, ] # trace_* insns are not compiled for now... @@ -549,8 +548,8 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L548 end end; assert_equal('0123456789', out) - errs = err.lines.reject do |l| - IGNORABLE_PATTERNS.any? { |pat| pat.match?(l) } + compactions, errs = err.lines.partition do |l| + l.match?(/\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods ->/) end assert_match(/\A#{JIT_SUCCESS_PREFIX}: block in <main>@-e:/, errs[0]) 9.times do |i| @@ -559,6 +558,10 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L558 assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10]) assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit9@\(eval\):/, errs[11]) + # On --jit-wait, when the number of JIT-ed code reaches --jit-max-cache, + # it should trigger compaction. + assert_equal(2, compactions.size) + # verify .o files are deleted on unload_units assert_send([Dir, :empty?, dir]) end Index: mjit.c =================================================================== --- mjit.c (revision 64096) +++ mjit.c (revision 64097) @@ -1219,7 +1219,8 @@ worker(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1219 #ifndef _MSC_VER /* Combine .o files to one .so and reload all jit_func to improve memory locality */ - if ((unit_queue.length == 0 && active_units.length > 1) || active_units.length == mjit_opts.max_cache_size) { + if ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1) + || active_units.length == mjit_opts.max_cache_size) { compact_all_jit_code(); } #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/