Conversation
jobarr-amzn
approved these changes
Sep 29, 2025
Contributor
jobarr-amzn
left a comment
There was a problem hiding this comment.
Good find. Is this one of the places where switching from an enum to an int flag might also yield benefit?
Contributor
Author
Oof, I hope not, but possibly... we should experiment with that. |
…it more efficiently, improving performance by up to 12%.
8c603fd to
a7c2b9f
Compare
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
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.
Description of changes:
In #790 (released in 1.11.5) we made
IonWriter.writeValues(IonReader)iterative instead of recursion in order to eliminate unbounded recursion from the library.While working on #1093 I noticed that this had caused negative performance impact for certain datasets:
Dataset: deeply nested single value
Benchmarking code: ion-java-benchmark-cli, modified so that the
readcommand testsIonWriter.writeValues(IonReader)with stream copy optimization disabled. I will formally add an option to the tool that does this in a separate PR.CLI command:
./benchmark-cli read --mode AverageTime --time-unit microseconds --iterations 2 --warmups 2 --forks 2 --ion-reader non_incremental --io-type buffer <file>1.11.4
Time: 38.788 us/op
1.11.5
Time: 42.918 us/op
1.11.8 (another regression happened here, related to the change to how PatchPoints are handled. This will be addressed separately)
Time: 44.937 us/op
This PR:
Time: 40.474 us/op
I identified this change by comparing CPU profiles. In 1.11.5,
IonWriter.setFieldNameSymbolshowed up at the top of the profile, whereas in 1.11.4 it was much lower. This is because in 1.11.4 it was JIT compiled, whereas in 1.11.5 it was simply inlined, which is much slower. JIT compilation can be limited by the size of the method, so I tried this and it worked.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.