jakartaee / jakartaee/jsonp-api
Each call to json.provider() is effectively call to class loader -> java.io.RandomAccessFile with locking
- Dominant language
- Java
- Stars
- 160
- Forks
- 64
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 4
Description
I recently discovered an throughput bottleneck within my micronaut application which using kafka streams and micnronaut serde. After using JFR, i see blocked threads on monitors on java.io.RandomAccessFile call.
After investigation, i found out that bottleneck happens when trying to [load class from classloader](https://github.com/jakartaee/jsonp-api/blob/master/api/src/main/java/jakarta/json/spi/JsonProvider.java#L122) - effectively calls RandomAccessFile with file locking.
Each time we call [Json.createGenerator](https://github.com/jakartaee/jsonp-api/blob/master/api/src/main/java/jakarta/json/Json.java#L98) with bytes we effectively will lock filesystem and block on monitor (if parallel processing happens)
I propose to cache generator in Api
Contributor guide
Research direction
Start with Json.java and its Json.createGenerator entry point, then read the linked JsonProvider.java implementation and the proposal to cache the generator in Api. Use the reported JFR scenario to verify that parallel calls no longer repeatedly load the provider or block on java.io.RandomAccessFile; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100