summaryrefslogtreecommitdiff
path: root/test/ruby/test_jit.rb
AgeCommit message (Collapse)Author
2018-08-11_mjit_compile_pc_and_sp.erb: always move pck0kubun
to fix the wrong line number on #caller_locations or rb_profile_frames. Actually we would be able to move it only when method call (of caller_locations) or C extension invocation (calling rb_profile_frames) can happen. This degrades performance. Optcarrot fps becomes... before: 71.78976052783555 after: 67.65429356624131 I think I can lazily move it and fix the performance issue, even improving the performance for the situation catch table exists. But let me fix this bug first... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09mjit.c: add :wait option to RubyVM::MJIT.pausek0kubun
and wait until JIT queue is flushed when wait option is not passed or `wait: true` is passed. vm.c: ditto test/ruby/test_rubyvm_mjit.rb: added test for pause/resume test/lib/jit_support.rb: allow retrying MJIT on JITSupport level test/ruby/test_jit.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07mjit.c: initial support for mswin MJITk0kubun
By this commit's changes in other files, now MJIT started to work on VC++. Unfortunately some features are still broken and they'll be fixed later. This also suppresses cl.exe's default output to stdout because there seems to be no option to do it. Tweaking some log messages as well. vm_core.h: declare `__declspec(dllimport)` to export them correctly on mswin. vm_insnhelper.h: ditto mjit.h: ditto test_jit.rb: skipped some pending tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-02test_jit.rb: split the test concernk0kubun
Actually unload_units is working on MinGW, but putiseq is behaving badly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-29test_jit.rb: skip known test failure on MinGWk0kubun
for the ease of MSP-Greg's CI. I'll track this failure as Bug#14948 and fix it later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-29test_jit.rb: use the appropiate namek0kubun
for better C-level backtrace git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-29mjit.c: disable compaction on empty queue w/ --jit-waitk0kubun
When --jit-wait is specified, `unit_queue.length` is always 0 and it's not a good metric. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-28mjit.c: introduce JIT compaction [experimental]k0kubun
When all compilation finishes or the number of JIT-ed code reaches --jit-max-cache, this compacts all generated code to a single .so file and re-loads all methods from it. In the future, it may trigger compaction more frequently and/or limit the maximum times of compaction to prevent unlimited memory usage. So the current behavior is experimental, but at least the performance improvement in this commit won't be removed. === Benchmark === In this benchmark, I'll compare following four conditions: * trunk: r64082 * trunk JIT: r64082 w/ --jit * single-so JIT: This commit w/ --jit * objfcn JIT: This branch https://github.com/k0kubun/ruby/tree/objfcn w/ --jit, which is shinh's objfcn https://github.com/shinh/ruby/tree/objfcn rebased from this commit ``` $ uname -a Linux bionic 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ``` * Micro benchmark Using this script https://gist.github.com/k0kubun/10e6d3387c9ab1b134622b2c9d76ef51, calls some amount of different methods that just return `nil`. The following tables are its average duration seconds of 3 measurements. Smaller is better. ** 1 method (seconds) | | trunk | trunk JIT | single-so JIT | objfcn JIT | |:------|:------------------|:------------------|:------------------|:------------------| | Time | 5.576067774333296 | 5.915551971666446 | 5.833641665666619 | 5.845915191666639 | | Ratio | 1.00x | 1.06x | 1.05x | 1.05x | ** 50 methods (seconds) | | trunk | trunk JIT | single-so JIT | objfcn JIT | |:------|:------------------|:------------------|:------------------|:------------------| | Time | 3.1661167996666677| 6.125825928333342 | 4.135432743666665 | 3.750358728333348 | | Ratio | 1.00x | 1.93x | 1.31x | 1.18x | ** 1500 methods (seconds) | | trunk | trunk JIT | single-so JIT | objfcn JIT | |:------|:------------------|:------------------|:------------------|:------------------| | Time | 5.971650823666664 | 19.579182102999994| 10.511108153999961| 10.854653588999932| | Ratio | 1.00x | 3.28x | 1.76x | 1.82x | * Discourse Using the same benchmark strategy as https://bugs.ruby-lang.org/issues/14490 with this branch https://github.com/k0kubun/discourse/commits/benchmark2 forked from discourse v1.8.11 to support running trunk. 1. Run ruby script/bench.rb to warm up profiling database 2. Run RUBYOPT='--jit-verbose=1 --jit-max-cache=10000' RAILS_ENV=profile bin/puma -e production 3. WAIT 5-15 or so minutes for all jitting to stop so we have no cross talk 4. Run ab -n 100 http://localhost:9292/ 5. Wait for all new jitting to finish 6. Run ab -n 100 http://localhost:9292/ ** Response time (ms) Here is the response time milliseconds for each percentile. Skipping 99%ile because it's the same as 100%ile in 100 calls. | | trunk| trunk|single|objfcn| | | | JIT|so JIT| JIT| |:----|:-----|:-----|:-----|:-----| | 50% | 38 | 45 | 41 | 43 | | 66% | 39 | 50 | 44 | 44 | | 75% | 47 | 51 | 46 | 45 | | 80% | 49 | 52 | 47 | 47 | | 90% | 50 | 63 | 50 | 52 | | 95% | 60 | 79 | 52 | 55 | | 98% | 91 | 114 | 91 | 91 | |100% | 97 | 133 | 96 | 99 | ** Ratio (smaller is better) Here is the response time increase ratio against no-JIT trunk's one. | | trunk| trunk|single|objfcn| | | | JIT|so JIT| JIT| |:----|:-----|:-----|:-----|:-----| | 50% | 1.00x| 1.18x| 1.08x| 1.13x| | 66% | 1.00x| 1.28x| 1.13x| 1.13x| | 75% | 1.00x| 1.09x| 0.98x| 0.96x| | 80% | 1.00x| 1.06x| 0.96x| 0.96x| | 90% | 1.00x| 1.26x| 1.00x| 1.04x| | 95% | 1.00x| 1.32x| 0.87x| 0.92x| | 98% | 1.00x| 1.25x| 1.00x| 1.00x| |100% | 1.00x| 1.37x| 0.99x| 1.02x| While 50 and 60 %ile are still worse than no-JIT trunk, 75, 80, 90, 95, 98 and 100% are not slower than that. So now it's a little harder to say "MJIT slows down Rails applications". Probably I can close [Bug #14490] now. Let's start improving it. Close https://github.com/ruby/ruby/pull/1921 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-27mjit.c: keep all .o filesk0kubun
and lazily delete them on termination. This will be needed to create a large so file later. The large number of .o files will be probably compacted before the large so file is created. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-27test_jit.rb: test unload_unitsk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24test_jit.rb: give up debugging cc1 issuek0kubun
in a short term, and add retries to prevent random CI failures by it. I remember this and will address it later for sure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24test_jit.rb: suppress unused variable warningk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-07insns.def: stop pushing unnecessary keys for MJITk0kubun
[Bug #14892] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-07_mjit_compile_insn_body: rollback pc correctlyk0kubun
for catch_except_p case Partially solving Bug#14892 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-05revert r62655 for r63763k0kubun
r63655 was tightly coupled to handle_frames and some assumptions seems to have been broken by r63763. To partially resolve Bug#14892, this reverts the optimization for now. I want to make MJIT CI happy first and then I'll probably retry r63655 by partially reverting r63763 for sp changes. The skipped test is not fixed yet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-15Remove warnings of flip-flop deprecation from tests and specsmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-22test_jit.rb: propagate suspicious stderrk0kubun
of child ruby process to parent stderr using `Kernel#warn`. This fixes a warning in {set,get}classvariable as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-09_mjit_compile_send.erb: revert r63350k0kubun
Revert "_mjit_compile_send.erb: inline recursive call" I reverted r63360 in r63379, but the errors were reproductive from r63350. So I need to revert this. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-07_mjit_compile_send.erb: inline recursive callk0kubun
mjit_compile.c: propagate funcname to compile_insn test_jit.rb: add test covering this behavior * Benchmark ``` require 'benchmark_driver' Benchmark.driver(runner: :time, repeat_count: 4) do |x| x.prelude %{ def fib(x) return x if x == 0 || x == 1 fib(x-1) + fib(x-2) end } x.report 'fib(40)' x.loop_count 1 x.rbenv( 'before,--jit', 'before', 'after,--jit', 'after', ) x.verbose end ``` ``` before,--jit: ruby 2.6.0dev (2018-05-08 trunk 63349) +JIT [x86_64-linux] before: ruby 2.6.0dev (2018-05-08 trunk 63349) [x86_64-linux] after,--jit: ruby 2.6.0dev (2018-05-08 trunk 63349) +JIT [x86_64-linux] last_commit=_mjit_compile_send.erb: inline recursive call after: ruby 2.6.0dev (2018-05-08 trunk 63349) [x86_64-linux] last_commit=_mjit_compile_send.erb: inline recursive call Calculating ------------------------------------- before,--jit before after,--jit after fib(40) 2.886 8.685 2.562 8.800 s - 1.000 times Comparison: fib(40) after,--jit: 2.6 s before,--jit: 2.9 s - 1.13x slower before: 8.7 s - 3.39x slower after: 8.8 s - 3.44x slower ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-03_mjit_compile_send.erb: retry inlining attr_readerk0kubun
This reverts r63249 (revert r63212) and fixes a bug in it. The test to prevent the bug is added as well. vm_insnhelper.c: add `index` argument to vm_getivar. The argument is created so that MJIT can pass the value of `cc->aux.index` on compilation time. The cache invalidation in _mjit_compile_send_guard.erb is only working for the cache value on compilation time. Note: As `index` is always passed as constant and it's force-inlined, the performance of `vm_getivar` won't be degraded in VM. _mjit_compile_send_guard.erb: New. Used to invalidate inlined values of cc. common.mk: update dependencies for _mjit_compile_send_guard.erb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02test_jit.rb: test local variablesk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02test_jit.rb: test opt_aref_with againk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02test_jit.rb: make it possible to automatically findk0kubun
untested insns. Resolved some warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02test_jit.rb: verify tested insnsk0kubun
and fix some untested insns git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02test_jit.rb: add missing dependencyk0kubun
The test works with make test-all, but I sometimes want to do a thing like: `.ruby-svn/ruby -Itest/lib test/ruby/test_jit.rb -n test_clean_so` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02compile.c: mark catch_except_p of iseqk0kubun
which has throw insn, not only ancestor iseqs of it. I think we should remove catch_except_p flag and try to simplify the catch table itself, to prevent similar bugs in the future. test_jit.rb: add test to prevent the bug git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-27mjit.c: clean so file on Windowsnobu
* mjit.c (dlclose): use FreeLibrary to manage the reference count on the loaded module properly. * mjit.c (clean_so_file): clean shared object file after unloaded, in-use files cannot be removed on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-21test_jit.rb: follow the change of instructionk0kubun
in r63225. Not strictly needed but to avoid confusion. The JIT compiler itself seems working fine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-20_mjit_compile_send.erb: inline attr_reader callk0kubun
_mjit_compile_send_guard.erb: carve out the shared logic to invalidate inlined method call common.mk: update dependency for this change test_jit.rb: add test for attr_reader optimization * Benchmark ``` require 'benchmark_driver' Benchmark.driver do |x| x.prelude %{ class C attr_reader :a def initialize @a = 1 end end o = C.new def l o i = 0 while i < 1000000 o.a i += 1 end end } x.report 'aread', %{ l o } x.loop_count 1000 x.rbenv 'before', 'before,--jit', 'after,--jit' x.verbose end ``` ``` before: ruby 2.6.0dev (2018-04-20 trunk 63211) [x86_64-linux] before,--jit: ruby 2.6.0dev (2018-04-20 trunk 63211) +JIT [x86_64-linux] after,--jit: ruby 2.6.0dev (2018-04-20 trunk 63211) +JIT [x86_64-linux] last_commit=_mjit_compile_send.erb: inline attr_reader call Calculating ------------------------------------- before before,--jit after,--jit aread 54.597 122.894 218.574 i/s - 1.000k times in 18.316102s 8.137089s 4.575106s Comparison: aread after,--jit: 218.6 i/s before,--jit: 122.9 i/s - 1.78x slower before: 54.6 i/s - 4.00x slower ``` * Optcarrot A little made faster? fps: 71.35 -> 72.11 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-30test_jit.rb: loosen CC check conditionk0kubun
see also: r63037. Probably it was not enough. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-29test_jit.rb: loosen debug log checkk0kubun
We couldn't catch log with https://gist.github.com/ko1/0fdc6a8d4add70cd8648000b16a3da38#file-brlog-trunk_gcc6-20180329-003723-L370 because the error message started with "gcc-6:". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-17test_jit.rb: debug cc1 availabilityk0kubun
ENV didn't have any useful information. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11test_jit.rb: show debugging output on stderrk0kubun
instead of stdout. We would not capture the output as test results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11test_jit.rb: fix typok0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-11test_jit.rb: add debugging outputk0kubun
Sometimes gcc fails to exec cc1 like this: https://gist.github.com/ko1/c3db8b193e9cc65c39c541e10d957509 I'm not sure why it happens at all. Please let me add this debugging output to inspect the random failure on CI for now. I'll remove this after we confirm it's not helpful. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-10compile.c: mark all ISeq ancestors as catch_except_pk0kubun
This change assumes that continuously reading `parent_iseq` from block ISeq would reach non-block ISeq finally. test/ruby/test_jit.rb: add test that catches 2-depth exception Combination of r62654 and r62678 caused following error in this test. -e:12:in `wrapper': Stack consistency error (sp: 14, bp: 13) (fatal) == disasm: #<ISeq:wrapper@-e:10 (10,0)-(12,3)> (catch: FALSE)=========== local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] paths<Arg> [ 1] prefixes<Arg> 0000 putself ( 11)[LiCa] 0001 getlocal_WC_0 paths 0003 getlocal_WC_0 prefixes 0005 opt_send_without_block <callinfo!mid:catch_true, argc:2, FCALL|ARGS_SIMPLE>, <callcache> 0008 leave ( 12)[Re] As you can see, it says `catch: FALSE`, but obviously it catches exception raised from `return path`. As of r62655, it was kind of intentional because I only cared about expiration of JIT-ed frame and I've thought calling `vm_exec` is only needed once for it. So r62654 was NOT actually checking if it may catch exception. But for r62678, obviously we should set catch_except_p=TRUE for all ISeqs which may catch exception. Otherwise catch table lookup would fail. With this bugfix, code generated by r62655 might be worse, but at least while loop can be marked as `catch: FALSE` as expected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-04mjit_compile.c: use local variables for stackk0kubun
if catch_except_p is FALSE. If catch_except_p is TRUE, stack values should be on VM's stack when exception is thrown and the JIT-ed frame is re-executed by VM's exception handler. If it's FALSE, the JIT-ed frame won't be re-executed and don't need to keep values on VM's stack. Using local variables allows us to reduce cfp->sp motion. Moving cfp->sp is needed only for insns whose handles_frame? is false. So it improves performance. _mjit_compile_insn.erb: Prepare `stack_size` variable for GET_SP, STACK_ADDR_FROM_TOP, TOPN macros. Share pc and sp motion partial view. Use cancel handler created in mjit_compile.c. _mjit_compile_send.erb: ditto. Also, when iseq->body->catch_except_p is TRUE, this stops to call mjit_exec directly. I described the reason in vm_insnhelper.h's comment for EXEC_EC_CFP. _mjit_compile_pc_and_sp.erb: Shared logic for moving sp and pc. As you can see from thsi file, when status->local_stack_p is TRUE and insn.handles_frame? is false, moving sp is skipped. But if insn.handles_frame? is true, values should be rolled back to VM's stack. common.mk: add dependency for the file _mjit_compile_insn_body.erb: Set sp value before canceling JIT on DISPATCH_ORIGINAL_INSN. Replace GET_SP, STACK_ADDR_FROM_TOP, TOPN macros for the case ocal_stack_p is TRUE and insn.handles_frame? is false. In that case, values are not available on VM's stack and those macros should be replaced. mjit_compile.inc.erb: updated comments of macros which are supported by JIT compiler. All references to `cfp->sp` should be replaced and thus INC_SP, SET_SV, PUSH are no longer supported for now, because they are not used now. vm_exec.h: moved EXEC_EC_CFP definition to vm_insnhelper.h because it's tighly coupled to CALL_METHOD. vm_insnhelper.h: Have revised EXEC_EC_CFP definition moved from vm_exec.h. Now it triggers mjit_exec for VM, and has the guard for catch_except_p on JIT-ed code. See comments for details. CALL_METHOD delegates triggering mjit_exec to EXEC_EC_CFP. insns.def: Stopped using EXEC_EC_CFP for the case we don't want to trigger mjit_exec. Those insns (defineclass, opt_call_c_function) are not supported by JIT and it's safe to use RESTORE_REGS(), NEXT_INSN(). expandarray is changed to pass GET_SP() to replace the macro in _mjit_compile_insn_body.erb. vm_insnhelper.c: change to take sp for the above reason. [close https://github.com/ruby/ruby/pull/1828] This patch resurrects the performance which was attached in [Feature #14235]. * Benchmark Optcarrot (with configuration for benchmark_driver.gem) https://github.com/benchmark-driver/optcarrot $ benchmark-driver benchmark.yml --verbose 1 --rbenv 'before;before+JIT::before,--jit;after;after+JIT::after,--jit' --repeat-count 10 before: ruby 2.6.0dev (2018-03-04 trunk 62652) [x86_64-linux] before+JIT: ruby 2.6.0dev (2018-03-04 trunk 62652) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-03-04 local-variable.. 62652) [x86_64-linux] last_commit=mjit_compile.c: use local variables for stack after+JIT: ruby 2.6.0dev (2018-03-04 local-variable.. 62652) +JIT [x86_64-linux] last_commit=mjit_compile.c: use local variables for stack Calculating ------------------------------------- before before+JIT after after+JIT optcarrot 53.552 59.680 53.697 63.358 fps Comparison: optcarrot after+JIT: 63.4 fps before+JIT: 59.7 fps - 1.06x slower after: 53.7 fps - 1.18x slower before: 53.6 fps - 1.18x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-22test_rubyoptions.rb: don't test --jit if not supportedk0kubun
test/lib/jit_support.rb: carved out JITSupport test/ruby/test_jit.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-13mjit_compile.inc.erb: replace opt_key insnk0kubun
with opt_send_without_block insn if call cache has valid ISeq. If the receiver is not optimized target of opt_key (i.e. Hash or Array), it triggers JIT cancel and it would be slow. This change allows JIT to drop the check for Hash/Array and continue to execute JIT even if the receiver is not Hash or Array. See the following benchmark results. It's not improved so much, but it would be effective when we achieve Ruby method inlining in _mjit_compile_send.erb. * Micro benchmark Given the following bench.rb, ``` class HashWithIndifferentAccess < Hash def []=(key, value) super(key.to_s, value) end def [](key) super(key.to_s) end end indhash = HashWithIndifferentAccess.new indhash[:foo] = 'bar' key = 'foo' 100000000.times do indhash[key] end ``` ** before ``` $ time ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb JIT success (31.4ms): block in <main>@/tmp/bench.rb:15 -> /tmp/_ruby_mjit_p18206u0.c JIT success (669.3ms): []@/tmp/bench.rb:6 -> /tmp/_ruby_mjit_p18206u1.c Successful MJIT finish ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb 12.21s user 0.04s system 107% cpu 11.394 total ``` ** after ``` $ time ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb JIT success (41.0ms): block in <main>@/tmp/bench.rb:15 -> /tmp/_ruby_mjit_p17293u0.c JIT success (679.0ms): []@/tmp/bench.rb:6 -> /tmp/_ruby_mjit_p17293u1.c Successful MJIT finish ./ruby --disable-gems --jit-verbose=1 /tmp/bench.rb 11.54s user 0.06s system 108% cpu 10.726 total ``` The execution time is shortened. * optcarrot benchmark Optcarrot has no room to be improved by this change. Almost nothing is changed. fps: 59.54 (before) -> 59.51 (after) * discourse benchmark I expected this to be improved a little, but it isn't too. ** before (JIT) ``` categories_admin: 50: 12 75: 13 90: 14 99: 22 home_admin: 50: 12 75: 13 90: 16 99: 22 topic_admin: 50: 12 75: 13 90: 15 99: 21 categories: 50: 18 75: 19 90: 23 99: 27 home: 50: 3 75: 4 90: 4 99: 12 topic: 50: 11 75: 11 90: 14 99: 20 ``` ** after (JIT) ``` categories_admin: 50: 12 75: 12 90: 16 99: 24 home_admin: 50: 12 75: 12 90: 14 99: 21 topic_admin: 50: 12 75: 13 90: 16 99: 21 categories: 50: 17 75: 18 90: 23 99: 32 home: 50: 3 75: 4 90: 4 99: 10 topic: 50: 11 75: 12 90: 13 99: 20 ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: prettify script in messagek0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: explicitly skip for unsupported onesk0kubun
MSP-Greg watches this metrics and this would be helpful for him. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-12test_jit.rb: split test_compile_insnsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-10test_jit.rb: cover most insn compilationsk0kubun
test_compile_insns has only basic tests to improve coverage. Other severer tests should be added with different names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09.travis.yml: force to execute JIT test on Travisk0kubun
test_jit.rb: with environment variable RUBY_FORCE_TEST_JIT, we can force to test JIT availability. I wanted to have such CI, but Travis was the only option which I can modify easily. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: don't force to test --jit-waitk0kubun
for platforms which can't use JIT. Such platforms can time out with eval_with_jit. http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/509911 http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/509904 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: fix typok0kubun
This is notified by zns-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: add forgotten checkk0kubun
I was going to check this in r62310... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: check JIT support more conservativelyk0kubun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: remove unnecessary requirek0kubun
At first I was going to check the name of `RbConfig::CONFIG['CC']` and use shellwords for it, but I decided not to do so. Thus removing obsoleted require in r62307. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08test_jit.rb: try to test JIT againk0kubun
This commit reverts r62297, revising the check if JIT is supported or not. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e