summaryrefslogtreecommitdiff
path: root/prism/defines.h
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2024-03-01 21:30:31 +0100
committergit <[email protected]>2024-03-04 16:41:16 +0000
commit6ad0f89d5aa2466cdfcd1a056ce9b28b39245033 (patch)
treeb8681cc021bb6229e9fd849518b1fdacec111d17 /prism/defines.h
parent03a73fdc3d5b612bba9a428b6680967b9189ee2d (diff)
[ruby/prism] Use a more efficient StringIO on TruffleRuby
* The stdlib StringIO is synchronized and this occurs a high overhead. * This is about twice as fast on TruffleRuby but surprisingly it is slower on JRuby. I am not sure why but probably @ivar access and integer arithmetic is much slower than Java field access/arithmetic on JRuby. * On CRuby interpreter it is slower, which is expected as the GVL already protects StringIO. * So we enable this only on TruffleRuby to not slow down other Rubies. * PRISM_FFI_BACKEND=true ruby -v -Ilib -rprism -rbenchmark -e '300.times { p Benchmark.realtime { Dir.glob("lib/**/*.rb") { |f| Prism.parse_file(f) } } }' ruby 3.3.0: 0.215 => 0.251 (cext: 0.062) ruby 3.3.0 YJIT: 0.118 => 0.113 (cext: 0.053) truffleruby JVM: 0.101 => 0.054 jruby 9.4.6.0: 0.162 => 0.219 jruby 9.4.6.0 indy: 0.078 => 0.086 * For the record here are the numbers for using the String directly, without a StringIO-like object: ruby 3.3.0: 0.215 => 0.234 (cext: 0.062) ruby 3.3.0 YJIT: 0.118 => 0.111 (cext: 0.053) truffleruby native: 0.101 => 0.053 jruby 9.4.6.0: 0.162 => 0.195 jruby 9.4.6.0 indy: 0.078 => 0.082 As we can see, that extra object adds a non-trivial overhead on CRuby interpreter and JRuby. But we need to make it possible to use StringIO and SimpleStringIO interchangeably. https://github.com/ruby/prism/commit/938677cbd2
Diffstat (limited to 'prism/defines.h')
0 files changed, 0 insertions, 0 deletions