refactor Jackson code to hardcode buffer-recycler#999
refactor Jackson code to hardcode buffer-recycler#999pjfanning wants to merge 1 commit intoplayframework:mainfrom
Conversation
029724d to
b3f7034
Compare
refactor Jackson code to hardcode buffer-recycler update jackson scalafmt Update JacksonJson.scala compile issue
|
I've used proposed changes to fix performance issues of play-json with latest jackson-core in this commit. Here is a screenshot of top-10 list of improved benchmarks when running with GraalVM JDK 22 on Intel® Core™ i9-13900K CPU having DDR5-4800 RAM using 16 threads (only performance core were enabled): Here are JMH result comparison pages for that and other JVMs using 16 threads on the same environment: |
| .builder() | ||
| .asInstanceOf[JsonFactoryBuilder] | ||
| .streamReadConstraints(streamReadConstraints) | ||
| .recyclerPool(JsonRecyclerPools.threadLocalPool()) |
There was a problem hiding this comment.
Jackson 2.17.0 used a very inefficient recycler pool that behaved even worse under heavy load - called 'Lock Free'. Jackson 2.17.1 and 2.17.2 (just released) goes back to ThreadLocalPool as the default. Still maybe a good idea to hardcode its use though.
|
@pjfanning I know Jackson 2.17.1 fixed things, but do you want to update the PR anyway to make things configurable, just like you did in Pekko? |
|
@mkurz this change is probably not needed now because the Jackson switch to a different buffer recycler was reverted |

Pull Request Checklist
Fixes
partial fix for #998
Purpose
What does this PR do?
Background Context
Why did you take this approach?
JsonFactory should be used to create ObjectMappers - not the other way around.
ThreadLocal buffer-recycler is the default up to and including Jackson 2.16. Default was changed in Jackson 2.17 but the way play-json uses Jackson is likely to suffer performance wise with the new default.
You might want to make the buffer-recycler configurable like in apache/pekko-http#519
Upgrading to Jackson 2.15 and above also brings in Jackson's StreamReadConstraints and StreamWriteConstraints.
play-json has its own number parsing checks so I disabled the Jackson check. There are other checks in StreamReadConstraints and StreamWriteConstraints and play-json needs to decide if you want to make them configurable or if you want to disable the Jackson checks.
References
Are there any relevant issues / PRs / mailing lists discussions?