Commit 737bb63
Improve JRuby perf. by removing source of multithreaded contention
The RuntimeInfo.forRuntime method synchronizes all invocations and
ParserSession#parseString was calling this many times when parsing
large JSON strings. Thus, when running in a heavily multithreaded
environment, threads were spending a large portion of their time
waiting on that synchronization instead of doing work parsing the
JSON.
This fix simply passes in the RuntimeInfo object to the ParserSession
when it's instantiated, since the RuntimeInfo is already known and
we've already incurred the synchronization cost at that time.
Using the test script at
https://gist.github.com/bbrowning/0b89580b03a5f19e7a9f, I get the
following results before and after this fix on my machine:
Before:
$ jruby ~/tmp/json_contention.rb
337.920000 0.570000 338.490000 ( 57.955000)
After:
$ jruby ~/tmp/json_contention.rb
326.400000 0.580000 326.980000 ( 43.084000)
That's a 25% reduction in processing time for parsing the same JSON on
my quad core machine. I'd expect an even higher percentage improvement
on a machine with more CPUs.1 parent f1b745e commit 737bb63
2 files changed
+91
-89
lines changed
0 commit comments