From: Phil Edelbrock Date: 2019-01-18T14:01:44-08:00 Subject: [ruby-core:91161] Re: Testing MJIT on RHEL 7.5 > On Jan 18, 2019, at 1:31 PM, Phil Edelbrock wrote: > > > >> On Jan 18, 2019, at 8:22 AM, Takashi Kokubun wrote: >> >> Hi, >> >>> time /usr/local/ruby-edge/bin/ruby --disable-gems --jit -e "5000000.times { 3 * 123 }" >>> real 0m0.229s >> >> 229ms is too short to measure JIT-ed code's performance. Because of this: >> >> $ time ./ruby --disable-gems -e "" >> ./ruby --disable-gems -e "" 0.00s user 0.00s system 95% cpu 0.005 total >> $ time ./ruby --disable-gems --jit -e "" >> ./ruby --disable-gems --jit -e "" 0.12s user 0.02s system 100% cpu 0.135 total >> >> large amount of time you measure would be just time consumed for >> stopping JIT thread. >> This behavior is limitation of JIT-ing by invoking C compiler, and >> this is something intentional for now. >> >> Due to that, what we can do for now is just like (this is ruby 2.6.0 >> x86_64-linux): >> >> $ time ./ruby --disable-gems -e "500000000.times { 3 * 123 }" >> ./ruby --disable-gems -e "500000000.times { 3 * 123 }" 13.24s user >> 0.00s system 99% cpu 13.242 total >> $ time ./ruby --disable-gems --jit -e "500000000.times { 3 * 123 }" >> ./ruby --disable-gems --jit -e "500000000.times { 3 * 123 }" 10.13s >> user 0.02s system 101% cpu 9.989 total >> >> Best, >> k0kubun >> >> 2019���1���18���(���) 10:34 Phil Edelbrock : >>> >>> >>> Hello, I'm new to this list. I hope this is the right place to ask questions about the new experimental JIT implementation (which looks incredibly cool). >>> >>> First, I've got both 2.6.0 installed and the latest from github (which I call 'edge') on RHEL 7.5: >>> >>> [pedelbro@966629-app3 ~]$ /usr/local/ruby-2.6.0/bin/ruby -v >>> ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux] >>> [pedelbro@966629-app3 ~]$ /usr/local/ruby-edge/bin/ruby -v >>> ruby 2.7.0dev (2019-01-16 trunk 66836) [x86_64-linux] >>> >>> gcc: >>> >>> Thread model: posix >>> gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) >>> >>> My /tmp is mounted (by default) as NOEXEC, so I created a regular directory in my home directory to get around the permissions error/warning: >>> >>> MJIT warning: failure in loading code from '/tmp/_ruby_mjit_p108878u0.so': /tmp/_ruby_mjit_p108878u0.so: failed to map segment from shared object: Operation not permitted >>> >>> So, now things seem better: >>> >>> MJIT: CC defaults to /usr/bin/gcc >>> MJIT: tmp_dir is /home/pedelbro/my_tmp >>> Creating precompiled header >>> Starting process: /usr/bin/gcc /usr/bin/gcc -std=gnu99 -w -Wfatal-errors -fPIC -shared -w -pipe -O3 -nodefaultlibs -nostdlib -o /home/pedelbro/my_tmp/_ruby_mjit_hp116911u0.h.gch /usr/local/ruby-edge/include/ruby-2.7.0/x86_64-linux/rb_mjit_min_header-2.7.0.h >>> start compilation: block in
@-e:1 -> /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.c >>> Starting process: /usr/bin/gcc /usr/bin/gcc -std=gnu99 -w -Wfatal-errors -fPIC -shared -w -pipe -O3 -o /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.o /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.c -c -lgcc -Wl,--compress-debug-sections=zlib -nostartfiles -nodefaultlibs -nostdlib >>> Starting process: /usr/bin/gcc /usr/bin/gcc -std=gnu99 -shared -Wfatal-errors -fPIC -shared -w -pipe -O3 -o /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.so /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.o -lgcc -Wl,--compress-debug-sections=zlib -nostartfiles -nodefaultlibs -nostdlib >>> JIT success (37.9ms): block in
@-e:1 -> /home/pedelbro/my_tmp/_ruby_mjit_p116911u0.c >>> >>> When testing, though, I only see slowdowns when turning on JIT? >>> >>> This is a simple (and maybe a bad) example: >>> >>> [pedelbro@966629-app3 models]$ time /usr/local/ruby-edge/bin/ruby --disable-gems --jit -e "5000000.times { 3 * 123 }" >>> >>> real 0m0.229s >>> user 0m0.383s >>> sys 0m0.049s >>> [pedelbro@966629-app3 models]$ time /usr/local/ruby-edge/bin/ruby --disable-gems -e "5000000.times { 3 * 123 }" >>> >>> real 0m0.208s >>> user 0m0.203s >>> sys 0m0.004s >>> >>> Thanks! Let me know if this is the wrong list to discuss this. I hope to be another datapoint for testing, if it helps. :') >>> >>> >>> Phil >>> >>> Unsubscribe: >>> > > > Hello Takashi! It is an honor to chat with you. I love your work. :') > > OK, so here's my output of your examples on both 2.6.0 and a semi-current edge. What am I doing wrong? What more info can I provide? > > > [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems -e "500000000.times { 3 * 123 }" > > real 0m19.632s > user 0m19.582s > sys 0m0.003s > [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems --jit -e "500000000.times { 3 * 123 }" > > real 0m20.480s > user 0m20.588s > sys 0m0.058s > [pedelbro@966629-app3 bin]$ ./ruby -v > ruby 2.7.0dev (2019-01-16 trunk 66836) [x86_64-linux] > > > [pedelbro@966629-app3 bin]$ cd /usr/local/ruby-2.6.0/bin > > [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems -e "500000000.times { 3 * 123 }" > > real 0m19.351s > user 0m19.300s > sys 0m0.005s > [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems --jit -e "500000000.times { 3 * 123 }" > > real 0m19.821s > user 0m19.899s > sys 0m0.061s > [pedelbro@966629-app3 bin]$ ./ruby -v > ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux] > > > Phil I'm sorry, I got tripped up again by the NOEXEC on my /tmp. Here's a better example and I do see improvement. (btw- I like how it falls back to regular ruby if JIT fails) [pedelbro@966629-app3 bin]$ mount | grep /tmp /dev/mapper/vglocal20180828-tmp00 on /tmp type ext4 (rw,nosuid,nodev,noexec,relatime,seclabel,stripe=64,data=ordered) [pedelbro@966629-app3 ~]$ export TMPDIR=~/my_tmp [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems --jit -e "500000000.times { 3 * 123 }" real 0m14.156s user 0m14.265s sys 0m0.050s [pedelbro@966629-app3 bin]$ time ./ruby --disable-gems -e "500000000.times { 3 * 123 }" real 0m18.465s user 0m18.417s sys 0m0.004s [pedelbro@966629-app3 bin]$ ./ruby -v ruby 2.7.0dev (2019-01-16 trunk 66836) [x86_64-linux] Phil Unsubscribe: