Linear performance test times out intermittently on JRuby
The linear timing test "test_read_directive_linear_performance" occasionally times out on JRuby. This does not likely indicate a failure to run the example in linear time as much as it reflects a sensitivity to very short timeouts. Until we fully understand why this test times out intermittently, I will omit it on JRuby.
The timeout failure produces the following output in CI:
Error: test_read_directive_linear_performance(TestRDocParserRuby): Timeout::Error: [100]: in 0.01s (tmin: 3.2501000021056825e-05, tmax: 7.660400001441303e-05, tbase: 1/1000)
org/jruby/ext/thread/Mutex.java:119:in `lock'
org/jruby/ext/thread/Mutex.java:181:in `synchronize'
/home/runner/.rubies/jruby-head/lib/ruby/stdlib/timeout.rb:93:in `finished'
/home/runner/.rubies/jruby-head/lib/ruby/stdlib/timeout.rb:191:in `block in timeout'
/home/runner/.rubies/jruby-head/lib/ruby/stdlib/timeout.rb:196:in `timeout'
/home/runner/work/rdoc/rdoc/vendor/bundle/jruby/3.1.0/gems/test-unit-ruby-core-1.0.6/lib/core_assertions.rb:836:in `block in assert_linear_performance'
org/jruby/RubyArray.java:2009:in `each'
/home/runner/work/rdoc/rdoc/vendor/bundle/jruby/3.1.0/gems/test-unit-ruby-core-1.0.6/lib/core_assertions.rb:831:in `assert_linear_performance'
/home/runner/work/rdoc/rdoc/test/rdoc/test_rdoc_parser_ruby.rb:[33](https://github.com/ruby/rdoc/actions/runs/13748754286/job/38447004956#step:5:34)87:in `test_read_directive_linear_performance'
3384:
3385: def test_read_directive_linear_performance
3386: pre = ->(i) {util_parser '# ' + '0'*i + '=000:'}
=> 3387: assert_linear_performance((1..5).map{|i|10**i}, pre: pre) do |parser|
3388: assert_nil parser.read_directive []
3389: end
3390: end
org/jruby/RubyKernel.java:1426:in `catch'
org/jruby/RubyKernel.java:1421:in `catch'
org/jruby/RubyArray.java:2009:in `each'
org/jruby/RubyArray.java:2009:in `each'
org/jruby/RubyArray.java:2009:in `each'
org/jruby/RubyKernel.java:1426:in `catch'
org/jruby/RubyKernel.java:1421:in `catch'
See comments here discussing this failure: https://github.com/ruby/rdoc/pull/1305#issuecomment-2708855316
@enebo This exercises our Java-based parser through Ripper. Can you think of any reason why it might occasionally parse slower, other than VM variability issues?
@headius It is a huge lists of lambdas being called from a single method. Any change in performance in executing the same code I think would be from the JVM deciding to compile stuff (which should happen up front). I would not expect it to be linear from that alone. Your comment (in linked issue) sounds right that they need a warmup cycle to measure linear performance.
If that does not explain it then we probably need to generate a histogram and see if there is something weird happening like a growing but removable data structure which is causing a large GC spike.