-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Make Parsing SnapshotInfo more Efficient #74005
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
Make Parsing SnapshotInfo more Efficient #74005
Conversation
Flatting the logic for parsing `SnapshotInfo` to go field by field like we do for `RepositoryData` which is both easier to read and also faster (mostly when moving to batch multiple of these blobs into one and doing on-the-fly filtering in an upcoming PR where the approach allows for more tricks). Also, simplified/deduplicated parsing out (mostly/often) empty lists in the deserialization code and used the new utility in a few more spots as well to save empty lists.
Pinging @elastic/es-distributed (Team:Distributed) |
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.
I left a couple of comments. Don't really follow why this is more efficient but it's certainly neater.
...r/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java
Show resolved
Hide resolved
this.indices = Collections.unmodifiableList(Objects.requireNonNull(indices)); | ||
this.dataStreams = Collections.unmodifiableList(Objects.requireNonNull(dataStreams)); | ||
this.featureStates = Collections.unmodifiableList(Objects.requireNonNull(featureStates)); | ||
this.indices = List.copyOf(indices); |
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.
Do these changes translate to 7.x ok? I guess we'll end up using org.elasticsearch.core.List#copyOf
which does a complete copy every time...
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.
Sort of ... I think we should fix the copy of behavior in 7.x
if it's inefficient in this spot but still nice to not have 5x deep nesting on this list in any case I guess :) I'll look into a 7.x
fix of that method later/next-week :)
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.
LGTM
Thanks David! |
Flatting the logic for parsing `SnapshotInfo` to go field by field like we do for `RepositoryData` which is both easier to read and also faster (mostly when moving to batch multiple of these blobs into one and doing on-the-fly filtering in an upcoming PR where the approach allows for more tricks). Also, simplified/deduplicated parsing out (mostly/often) empty lists in the deserialization code and used the new utility in a few more spots as well to save empty lists.
Flatting the logic for parsing `SnapshotInfo` to go field by field like we do for `RepositoryData` which is both easier to read and also faster (mostly when moving to batch multiple of these blobs into one and doing on-the-fly filtering in an upcoming PR where the approach allows for more tricks). Also, simplified/deduplicated parsing out (mostly/often) empty lists in the deserialization code and used the new utility in a few more spots as well to save empty lists.
Flatting the logic for parsing
SnapshotInfo
to go field by field like we do forRepositoryData
which is both easier to read and also faster (mostly when moving to batch multiple of these blobs into one
and doing on-the-fly filtering in an upcoming PR where the approach allows for more tricks).
Also, optimized/deduplicated the logic for parsing out (mostly/often) empty lists in the deserialization code
and used the new utility in a few more spots as well to save empty lists.
Lastly, fixed the at times very deeply nested
Collections.unmodifiableList(
chains that the way the duplicate constructors for x-content parsing and normal construction would cause.