-
-
Notifications
You must be signed in to change notification settings - Fork 812
add NonBlockingByteBufferJsonParser (and refactor some NonBlockingJsonParser code to make it more extensible) #795
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
Conversation
src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java
Outdated
Show resolved
Hide resolved
Yeah, I am specifically worried about performance aspects since byte access is, well, once (or more) per input byte. Alternatively if we could find out hot spots -- maybe a small portion of accesses could be left for concrete classes to implement -- we could perhaps have hybrid model to balance need to re-implement only a small set of methods (with hard-coded access). I haven't checked code to see if that is at all feasible, will have a look next. It definitely would be nice to support |
@cowtowncoder this still far from complete and needs testing and more specifically, perf testing. I have pushed on and created NonBlockingUtf8JsonParserBase which has most of the code from NonBlockingJsonParser. NonBlockingByteBufferJsonParser extends NonBlockingUtf8JsonParserBase. The idea is to have NonBlockingJsonParser also extend NonBlockingUtf8JsonParserBase but I've left that for a few days so that it is visible how much code has changed in NonBlockingJsonParser in order to not have the methods work directly on the |
@cowtowncoder does this look a reasonable perf test? I need to try it with more permutations but on Zulu JDK 1.8.0_332, I get these results: v2.14 without refactor: v2.14 with refactor: v2.13.3: So far, it looks like the refactor has not has a noticeable impact on performance - at least in this test case. |
@pjfanning Thanks, I need to have a look. It sounds legit, although ideally test would exercise different token types and access content. But then again, there are so many different aspects (in most tests the whole content is fed as a big chunk, vs. smaller pieces). But I think at least we can rule out obvious drastic negative effects. Fwtw, jackson-benchmarks: https://github.com/FasterXML/jackson-benchmarks/ also has non-blocking/async test variants so maybe I could find time to test it as well. |
Thanks for pointing me towards jackson-benchmarks. I ran one of the existing benchmarks and got these numbers (Zulu JDK 1.8.0_332): 2.13.3 2.14 without refactor 2.14 with refactor |
Ah ha! Well now that is interesting. :) I think I am fine proceeding with this PR then; perhaps we could get |
@pjfanning As per above, just let me know when you think this should be ready and I can review with more thought (it all looks good so far!) and get it merged. Not sure how easy it is to extend existing byte[]-backed tests to also do variant on |
@cowtowncoder this PR has the byte buffer code too - see https://github.com/FasterXML/jackson-core/pull/795/files#diff-1cce0198eb8bfe42fcfac3e075d09d858c2bf8b198b777297f943ab4f1731361 I also added createNonBlockingByteBufferParser() to JsonFactory. I took a few of the byte[] array tests and made them run with the byte buffer too. |
I will try to get this reviewed and merged soon (this week has been hectic but next week I'll have much more time for Jackson again!) |
@pjfanning Ok, I probably should have merged PRs in different order, but looks like there's a conflict. Could you resolve that? I'll merge this ASAP when that is done. |
@cowtowncoder thanks for merging the other PRs - the async number parsing test one was always going to conflict with this - I think I've got those changes merged in here now to fix the conflict. |
Thank you @pjfanning ! Yeah, minor conflicts are to be expected. Will now merge. |
Ugh. This will require some care merging to 3.0 :) |
Took a while but merging successful. :) |
Relates to #478