Skip to content

Integrate WASM-based Prism parser into standard build#9184

Draft
headius wants to merge 7 commits intojruby:masterfrom
headius:wasm_prism
Draft

Integrate WASM-based Prism parser into standard build#9184
headius wants to merge 7 commits intojruby:masterfrom
headius:wasm_prism

Conversation

@headius
Copy link
Copy Markdown
Member

@headius headius commented Jan 22, 2026

This continues the integration of Prism parser wrapper libraries from the jruby-prism project by shading it in and including the new WASM support and Chicory libraries.

This is a prototype of how it should eventually look and this PR is intended to iterate.

Notable behavior changes so far:

  • If the prism parser is enabled with -Xparser.prism but the dynamic library is not configured or present, it will fall back on the wasm parser.
  • If the prism parser is enabled with -Xparser.prism.wasm the wasm parser will be used.
  • The parser statistics output now prints the actual parser class in use.
  • All dependencies are shaded in and moved to internal packages as appropriate.

The artifacts this depends on comes from:

@headius headius added this to the JRuby 10.1.0.0 milestone Jan 22, 2026
@headius
Copy link
Copy Markdown
Member Author

headius commented Jan 22, 2026

Performance of a "gem list" benchmark with legacy parser versus wasm prism (after sufficient warmup):

legacy:

Parser Statistics:
  Generic:
    parser type: class org.jruby.parser.Parser
    bytes processed: 1451897
    files parsed: 155
    evals parsed: 145
    time spent parsing(s): 0.028649121
    time spend parsing + building: 0.040757128000000004
  IRBuild:
    build time: 0.012108007

wasm prism:

Parser Statistics:
  Generic:
    parser type: class org.jruby.prism.parser.ParserPrismWasm
    bytes processed: 1849537
    files parsed: 155
    evals parsed: 145
    time spent parsing(s): 0.383976125
    time spend parsing + building: 0.39173020000000003
  Prism:
    time C parse+serialize: 0.0
    time deserializing: 0.009623121
    serialized bytes: 1224017
    serialized to source ratio: x0.66179645
  IRBuild:
    build time: 0.007754075

Wierdly this runs much better with tiered compilation turned off (-J-XX:-TieredCompilation):

Parser Statistics:
  Generic:
    parser type: class org.jruby.prism.parser.ParserPrismWasm
    bytes processed: 1849537
    files parsed: 155
    evals parsed: 145
    time spent parsing(s): 0.07803804
    time spend parsing + building: 0.085966137
  Prism:
    time C parse+serialize: 0.0
    time deserializing: 0.008756323
    serialized bytes: 1224017
    serialized to source ratio: x0.66179645
  IRBuild:
    build time: 0.007928097

@headius
Copy link
Copy Markdown
Member Author

headius commented Jan 22, 2026

Benchmark command line:

jruby -J-XX:-TieredCompilation -Xparser.summary -Xparser.prism -e 'loop { t = Time.now; ruby = org.jruby.Ruby.newInstance; ruby.loadService.require("rubygems"); ruby.loadService.require("rubygems/gem_runner"); ruby.evalScriptlet("Gem::GemRunner.new.run [%{list}]"); ruby.tearDown; $stderr.puts Time.now - t }'

Remove -Xprism.parser or the tiered compilation flag to test without them.

@CufeHaco

This comment was marked as off-topic.

@CufeHaco

This comment was marked as off-topic.

@CufeHaco

This comment was marked as off-topic.

@enebo

This comment was marked as off-topic.

@CufeHaco

This comment was marked as off-topic.

@CufeHaco

This comment was marked as off-topic.

This integrates jruby-prism 2.0 by shading it into our main JRuby
jar and loading it from there. Incoming packages considered to be
for internal use are moved under `org.jruby.internal`. The output
of parser statistics now shows the actual class of the parser,
since either or both can be activated now.
If this is parsed by Prism, it's a ProgramNode contained in a
ParseResult, so just use the ParseResult.
@headius headius changed the base branch from 10.1-dev to master February 24, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants