-
Notifications
You must be signed in to change notification settings - Fork 7
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
Loader rewrite #100
Loader rewrite #100
Conversation
023fdbd
to
a474c4c
Compare
Is the win here predominantly from branching reduction? Can you say anything else about performance in theory or practice of the pieces here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet. Nice win!
My only specific question is if making the IonReader.forEachValue
method inline
with a crossinline
block param would help be the same win here and wherever else it was used.
It's not practical to try to attribute specific amounts of improvement to specific parts of the change (I'd have to test the individually, and hope that the sum of the parts is equal to the whole, which is not guaranteed on the JVM). However, here is a list of the things that I did which, in theory, should all contribute to the improvement:
I don't know because I did not test that. Since it was private to this file, I just got rid of the function entirely. |
Issue #, if available:
None. However, an offline discussion with someone who was trying out
IonElement
indicated that loading all values asIonElement
was allocating up to 4x as memory as compared to loading the equivalent data asIonValue
.Description of changes:
This rewrites the
loadCurrentElement
function to eliminate some unnecessary allocations, and minimize the amount of branching in this function. The result is a very modest memory improvement, but a fairly decent speed improvement, and the size of the compiled bytecode of the rewritten function is about 40% of that of the current version of the function.Performance testing results
Using arbitrary data that I put together from a few different sources (~5kB)
0.053 ± 0.001
81128.034 ± 0.004
0.047 ± 0.001
215416.030 ± 0.004
0.032 ± 0.001
131720.020 ± 0.003
Ion binary application log file (~20 MB)
635.450 ± 75.384
625408257.218 ± 49.211
630.640 ± 215.099
2348935671.047 ± 146.942
452.451 ± 283.069
2245469209.217 ± 113.536
Sample catalog data (~40 kB)
0.616 ± 0.093
696584.433 ± 0.297
0.559 ± 0.028
2999688.359 ± 0.046
0.513 ± 0.007
2854072.329 ± 0.041
This was not as much of an improvement as I had hoped, but I will be following up this PR with another change that is orthogonal to this that should have a more significant impact on the memory allocation rate.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.