Open eregon opened 1 year ago
One longer-term solution is using the new Ruby parser YARP, which should be able to emulate Ripper and that parser would run natively not on Sulong.
With #3118 Ripper is now executed natively and so Ripper (and notably ripper_yyparse
) is compiled by gcc/clang.
It's about 10 times faster:
$ ruby -rbenchmark -rripper -e 'c=File.binread("src/main/ruby/truffleruby/core/io.rb"); 10.times { p Benchmark.realtime { Ripper.sexp(c) } }'
using last iteration, all Oracle GraalVM
TruffleRuby 23.1.1 JVM
4.14s
TruffleRuby 23.1.1 Native
9.8s
master Native
0.55s
master JVM
0.48s
Still slower than CRuby 3.2.2 which does it in 0.008s though.
The cause is pretty clear, here it's from running the
ruby-lsp
benchmark (withgem "syntax_tree", "4.0.2"
):The first two relate to https://github.com/oracle/truffleruby/issues/2290#issuecomment-1277796067 / https://github.com/whitequark/parser/issues/871, a separate issue.
So
ripper_yyparse
fails to be compiled because too big.@rschatz Does Sulong use BlockNode or could it? Maybe only for basic blocks without control flow? But I'm not sure it would help then.
BTW, it'd be useful if Sulong shows the end line of functions (even if it's an approximation), because
ripper.c~6157:0
doesn't tell us.ripper_yyparse
is 6686 lines long: https://github.com/oracle/truffleruby/blob/c9c717bf822deb4d5592eeedc05d1842bf72b88d/src/main/c/ripper/ripper.c#L6162-L12848(and
parser_yylex
is 707 lines long)