flori/json — pull request #226 by bbrowning (2014-12-16 15:14:31+00:00)
Title: 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.