-
Notifications
You must be signed in to change notification settings - Fork 327
Replace Jackson with DSL-JSON #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 23, 2018
Log JSON on trace level Signed-off-by: Felix Barnsteiner <felix.barnsteiner@elastic.co>
Merged
(closes elastic#23) Signed-off-by: Felix Barnsteiner <felix.barnsteiner@elastic.co>
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
============================================
+ Coverage 75.29% 76.55% +1.25%
- Complexity 547 637 +90
============================================
Files 71 71
Lines 1919 2354 +435
Branches 146 187 +41
============================================
+ Hits 1445 1802 +357
- Misses 397 448 +51
- Partials 77 104 +27
Continue to review full report at Codecov.
|
This was referenced Mar 7, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Benchmarking shows that serializing payloads with dsl-json is x2.4 faster and requires -86% less allocations.
DSL-JSON is a nice library which focuses on fast and garbage free JSON serialization. It only has a small byte[] buffer, which is reused and otherwise directly writes into a
OutputStream, so there are no temporary objects created. It also has a mode where it can automatically serialize annotated POJOs. I opted for a more manual approach to have more control about the resulting JSON (seehasContent()checks and explicitly serializingTransactionIdwithUUIDConverter.serialize(id.getMostSignificantBits(), id.getLeastSignificantBits(), jw);)My recent additions to dsl-json ngs-doo/dsl-json#48 and ngs-doo/dsl-json#49 make it possible to also serialize
StringBuildersand transaction ids in the UUID format in a garbage free way. The only thing which requires allocations now is creating a ISO date formatted string for theTransaction.timestampand creatingMap.entrySet().iterator()s for iterating over customContext.tags. I'm not quite sure why JIT can't replace the iterator heap allocations with stack allocations, but maybe JMH's GC profiler also reports stack allocations ingc.alloc.rate.norm. Regarding the timestamp serialization, there is an open issue about adding support for epoch timestamps: elastic/apm-server#850. That would make the JSON serialization essentially completely garbage free.As an additional benefit, the total size of the agent jar drops from 2.8 to 1.2 mb as the replaced Jackson library is much heavier.
This PR is currently blocked until dsl-json 1.7.4 is released.