Optimizing Variant read path with lazy caching#3481
Open
nssalian wants to merge 1 commit intoapache:masterfrom
Open
Optimizing Variant read path with lazy caching#3481nssalian wants to merge 1 commit intoapache:masterfrom
nssalian wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
steveloughran
left a comment
There was a problem hiding this comment.
code looks good; made some minor changes.
This should make a very big difference when selectively retrieving multiple fields within a single variant, or within a variant and nested children.
I do worry about concurrency now. The existing Variant didn't have issues here precisely because it recalculated everything.
We have to be confident that even if concurrent access triggers a duplicate cache operation, there's no harm in this. Otherwise cache access will have to be synchronized.
It all looks good to me.
Contributor
|
I started the workflows |
Co-authored-by: Steve Loughran <stevel@cloudera.com>
6c6db2e to
6f540f4
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.
Rationale for this change
Profiling in 3452 identified
Variant.getFieldAtIndex()and metadata string lookups as hotspots during variant reads. Every call togetFieldByKey,getFieldAtIndex, andgetElementAtIndexre-parses headers and re-allocates objects that could be cached.What changes are included in this PR?
Adds lazy caching to
Variant.javafor metadata strings, object headers, and array headers. Field lookups ingetFieldByKeynow defer value construction until a match is found, and child Variants share the parent's metadata cache. Also removes two unused static helper methods.Includes @steveloughran's string converter optimization from #3452:
VariantBuilder.appendAsString(Binary)and its use inVariantConverters.Are these changes tested?
Ran the benchmarks from 3452 locally
Before:
After:
Most recent benchmarks after the thread safety changes
Are there any user-facing changes?
No.