-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Short-Circuit NOOP Mapping Updates Earlier #77574
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,16 +271,22 @@ public DocumentMapper merge(String type, CompressedXContent mappingSource, Merge | |
return mergeAndApplyMappings(type, mappingSource, reason); | ||
} | ||
|
||
private synchronized DocumentMapper mergeAndApplyMappings(String mappingType, CompressedXContent mappingSource, MergeReason reason) { | ||
Mapping incomingMapping = parseMapping(mappingType, mappingSource); | ||
Mapping mapping = mergeMappings(this.mapper, incomingMapping, reason); | ||
DocumentMapper newMapper = newDocumentMapper(mapping, reason); | ||
if (reason == MergeReason.MAPPING_UPDATE_PREFLIGHT) { | ||
private DocumentMapper mergeAndApplyMappings(String mappingType, CompressedXContent mappingSource, MergeReason reason) { | ||
final DocumentMapper currentMapper = this.mapper; | ||
if (currentMapper != null && currentMapper.mappingSource().equals(mappingSource)) { | ||
return currentMapper; | ||
} | ||
synchronized (this) { | ||
Mapping incomingMapping = parseMapping(mappingType, mappingSource); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can probably be outside the synchronized block as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically I think so yes. But the parsing code does reference |
||
Mapping mapping = mergeMappings(this.mapper, incomingMapping, reason); | ||
DocumentMapper newMapper = newDocumentMapper(mapping, reason); | ||
if (reason == MergeReason.MAPPING_UPDATE_PREFLIGHT) { | ||
return newMapper; | ||
} | ||
this.mapper = newMapper; | ||
assert assertSerialization(newMapper); | ||
return newMapper; | ||
} | ||
this.mapper = newMapper; | ||
assert assertSerialization(newMapper); | ||
return newMapper; | ||
} | ||
|
||
private DocumentMapper newDocumentMapper(Mapping mapping, MergeReason reason) { | ||
|
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.
Maybe we should take the action off the transport thread, seems like an action that do not need to run on transport and now that we compress, we do a bit (though tiny) of real work 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.
I thought about this, but it seemed like the wrong approach. Either, and this is true IMO, the compression cost is so tiny here that it doesn't matter really. Or if it does indeed matter, the better fix seems to be to just serialize the
PutMappingRequest
with the mapping in compressed form right away (thus making it smaller and easier to read from the wire as well).