-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
JSON vs CBOR performance for ASCII text #519
Comments
Ok, first, I am bit surprised by your findings; my benchmarks with https://github.com/FasterXML/jackson-benchmarks/ have found CBOR codec a bit faster than JSON one. Second: I think Java 17 and later screwed up performance of As to constructing |
Oh, also, given these are quite small documents as well, I wonder if profiled (like Java async-profiler) might find. I assume tests were run with JDK 17, as per pom.xml. |
Hi Tatu, thanks for the quick response.
OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS)
OpenJDK Runtime Environment Corretto-8.422.05.1 (build 1.8.0_422-b05)
|
First of all: yes, PR would be welcome! One question/suggestion: This test case:
seems to have error range as big as value so tests probably need to run for many more iterations. Another note:
Yes -- these are related to going from |
Great, 😄
Ugh, 🤦♂️, thanks for pointing it out, let's try again
Yeah, I bet they are heavily beating on the prominence of latin1, which at least for us is true 😉, let me see what I can come up with, thanks again! |
Hi there,
We're testing the performance of CBOR vs plain JSON and looks like, at least for ASCII text, JSON is quite faster, this speaks volumes about the Jackson performance of JSON but looks like CBOR still has room for improvement.
The performance tests can be found on this repository. For a simple class with five
String
fields and ASCII (non-escaped) strings JSON is almost twice as fast as CBOR for larger strings (between 193 and 231 chars)As expected, this is not the case for multi-byte chars, for instance, chars from the CJK block, emojis or full ASCII (some of which requires escaping in plain JSON). See below
Given the prevalence of ASCII text it would be great if the performance could be at least as good but I feel that it should be better.
I played a bit with the loop in tight loop inside
_finishShortText
(see here) and I see some improvements but not consistent across architectures (better for my M1 laptop, not so much for x86).I also played a bit with creating the
String
directly from the input buffer and letting Java take care of UTF8 (see here, missing some other spots and possibly flawed as I was just playing), that approach looks promising (see below) but has a drawback, it won't be able to detect malformed UTF-8 as Jackson does now. I think it can be added behind a feature flag for when we know and trust the source of the data.Any thoughts, better ideas?
The text was updated successfully, but these errors were encountered: