Visitar URL original
Consider lowering JIT_MAXSIZE · Issue #9861 · jruby/jruby · GitHub
Skip to content

Consider lowering JIT_MAXSIZE #9861

Closed

Description

@headius

Currently, JIT_MAXSIZE (org.jruby.util.cli.Options.JIT_MAXSIZE, configured by property jruby.jit.maxsize) is set to 3000 IR instructions. This limit appears to be larger than all but 2 code bodies in the .rb sources included in a JRuby dev environment.

During the update of ASM to 9.11.1 (#9858) we discovered that 11 large bodies would be compiled by JRuby under our max size limit, but ultimately fail ASM's new bytecode size and count limits:

  • lib/ruby/stdlib/date/format.rb:196 (method _parse_ddd)
  • lib/ruby/stdlib/mkmf.rb:2180 (method create_makefile)
  • spec/ruby/core/string/undump_spec.rb:5 (block)
  • spec/ruby/core/string/undump_spec.rb:158 (block)
  • spec/ruby/library/uri/plus_spec.rb:5 (block)
  • spec/ruby/library/uri/plus_spec.rb:43 (block)
  • test/mri/openssl/test_asn1.rb:7 (method test_decode_x509_certificate)
  • test/mri/ruby/test_call.rb:510 (method test_call_cfunc_splat_large_array_bug_4040)
  • test/mri/ruby/test_complex.rb:786 (method test_parse)
  • test/mri/ruby/test_keyword.rb:292 (method test_keyword_splat_new)
  • test/mri/ruby/test_keyword.rb:2477 (method test_ruby2_keywords)

Note that most of these are test bodies, which are frequently large and normally won't JIT, but the __parse_ddd method in date.rb is more likely to be used by real-world applications.

The create_makefile method also likely only runs a few times, during installation of gems that include C libraries (rare on JRuby).

Some of these bodies, such as the spec block for spec/ruby/library/uri/plus_spec.rb, also exceed the 10MB size limit in ASM. Such large methods will certainly never be JIT compiled by the JVM, and as a result they will probably be more efficient (and use less memory) if they remain in the interpreter.

I believe we should reexamine the max JIT method size and probably drop it down from the current 3000 IR instructions to a more reasonable 1000 instructions or lower.

Activity

  1. added this to the JRuby 10.1.3.0 milestone on Oct 20, 2026
  2. headius commented on Oct 20, 2026

    @headius
    MemberAuthor

    Dropping the limit to 1000 IR instructions only increases the "too large to JIT" count to 10 bodies out of all bodies in the JRuby workspace.

    At 500 instructions, it only goes up to 33.

    I must admit I'm surprised there aren't more methods that would be rejected.

  3. added a commit that references this issue on Oct 22, 2026
  4. linked a pull request that will close this issueReduce default max JIT size to 500 #9867on Oct 22, 2026
  5. headius commented on Oct 22, 2026

    @headius
    MemberAuthor

    JIT max size (in IR instructions) has been reduced to 500, still very large but a good step. We're doing this conservatively and will continue exploring the balance between interpreter, bytecode and JVM JIT of large Ruby methods.

  6. added a commit that references this issue on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions