1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test
k0kubun 443f4d583c mjit.c: introduce JIT compaction [experimental]
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-28 16:14:56 +00:00
..
-ext- test/-ext-/gvl/test_last_thread.rb: skip under MJIT 2018-07-20 22:30:39 +00:00
base64
benchmark
bigdecimal
cgi Revert "ext/cgi/escape: preserve String subclass in result" 2018-05-03 01:24:09 +00:00
coverage
csv Merge csv-1.0.2 from upstream. 2018-05-09 04:39:16 +00:00
date test/date/test_date_base.rb: removed 2018-04-17 08:18:56 +00:00
dbm
digest
drb
dtrace test/dtrace/helper.rb: support systemtap in dtrace tests 2018-06-05 21:19:50 +00:00
erb
etc
excludes
fiddle test_function.rb: fix messages 2018-07-28 13:06:43 +00:00
fileutils Retry to merge fileutils-1.1.0. 2018-05-15 05:53:18 +00:00
gdbm Use assert(false) for the path that is expected unreachable 2018-04-17 08:18:57 +00:00
io test/io/console/test_io_console.rb: fix for systems where PTY is not defined 2018-06-06 01:12:23 +00:00
irb irb.rb: update _ 2018-05-12 09:13:45 +00:00
json
lib test_jit.rb: test unload_units 2018-07-27 05:52:01 +00:00
logger
matrix
minitest use https:// instead of http:// 2018-07-28 10:00:27 +00:00
misc
mkmf
monitor
net increase body size 2018-06-25 12:11:31 +00:00
nkf
objspace
open-uri
openssl openssl: merge changes in v2.1.1 2018-05-12 07:33:53 +00:00
optparse optparse: Suppress warnings 2018-05-06 09:53:33 +00:00
ostruct
pathname
psych Merge Pysch 3.0.3.pre1. 2018-04-28 01:47:58 +00:00
rdoc Merge rdoc-6.0.4 from upstream. 2018-05-08 02:07:53 +00:00
readline
resolv
rexml rexml: disable XPath 1.0 compatible "#{ELEMENT_NAME}" processing by default 2018-04-28 01:36:18 +00:00
rinda
ripper
rss rss: Add option Hash support to RSS::Parser.parse 2018-05-12 09:06:00 +00:00
ruby mjit.c: introduce JIT compaction [experimental] 2018-07-28 16:14:56 +00:00
rubygems Skip more rubygems tests when openssl is missing 2018-07-04 12:45:46 +00:00
scanf
sdbm
shell Promote Shell library to default gems. 2018-07-20 02:24:59 +00:00
socket test/socket/test_socket.rb (test_timestamp): retry send 2018-07-07 05:34:03 +00:00
stringio
strscan
syslog
testunit Use &. instead of modifier if 2018-06-10 03:10:13 +00:00
thread test/thread/test_cv.rb: test CV usability inside forked child 2018-04-30 23:53:55 +00:00
uri http_proxy setting should respect both parent domain and subdomain 2018-05-17 07:40:01 +00:00
webrick Add missing escape 2018-07-26 12:47:01 +00:00
win32ole
yaml
zlib test/zlib/test_zlib.rb (test_path): enable the accidentally-disabled assertion 2018-04-17 06:38:08 +00:00
colors
runner.rb
test_abbrev.rb
test_cmath.rb
test_delegate.rb
test_extlibs.rb
test_find.rb
test_forwardable.rb
test_ipaddr.rb
test_mutex_m.rb
test_observer.rb
test_open3.rb Remove needless closed? 2018-06-17 15:42:35 +00:00
test_pp.rb
test_prettyprint.rb
test_prime.rb test/test_prime.rb: add testcases of prime library 2018-06-24 09:31:06 +00:00
test_pstore.rb
test_pty.rb Remove needless lines 2018-06-12 14:36:32 +00:00
test_rbconfig.rb
test_securerandom.rb
test_set.rb
test_shellwords.rb
test_singleton.rb
test_syslog.rb
test_tempfile.rb Failed to unlink before close on mswin 2018-07-11 13:00:56 +00:00
test_time.rb time.rb: yday support 2018-07-24 07:47:01 +00:00
test_timeout.rb
test_tmpdir.rb test/test_{tempfile,tmpdir}: get rid of leftover files 2018-07-11 08:33:37 +00:00
test_tracer.rb
test_tsort.rb
test_unicode_normalize.rb fix range check for Hangul jamo trailers in Unicode normalization 2018-07-28 09:44:33 +00:00
test_weakref.rb
test_win32api.rb