Refactor lock and simplify maps#200
Closed
Bukhtawar wants to merge 10 commits intoalchemist51:cieefrom
Closed
Conversation
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com> Co-authored-by: Bukhtawar Khan <bukhtawa@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
18fa84c to
c5a4fc5
Compare
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> Co-authored-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
c942b9c to
530d346
Compare
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
fc6e33a to
a37d2ef
Compare
Owner
|
We will get back on the lockable pool later |
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
CompositeWriter.java — Replaced the Map.Entry<DataFormat, Writer<DocumentInput<?>>> primary writer field with two plain fields (primaryFormat and primaryWriter), eliminating the AbstractMap.SimpleImmutableEntry allocation and .getKey()/.getValue() indirection at every call site. Switched secondaryWritersByFormat from LinkedHashMap to IdentityHashMap wrapped with Collections.unmodifiableMap(), so lookups in addDoc() use == reference equality instead of String.equals() on format names.
CompositeDocumentInput.java and CompositeIndexingExecutionEngine.java — Switched secondary input maps from LinkedHashMap/Map.copyOf() to IdentityHashMap/Collections.unmodifiableMap() to preserve identity semantics end-to-end, since the same DataFormat singleton instances flow from engine construction through document input creation to writer lookup.
CompositeDataFormatWriterPool.java — Replaced the checkoutAll() implementation with an atomic swap pattern. The old version held the pool lock while iterating all writers, locking each one, and removing each from the striped queue (N×16 lock acquisitions). The new version holds the pool lock only for two pointer swaps (microseconds), then waits for in-flight writes outside any pool lock. Updated releaseAndUnlock() to gracefully handle old-generation writers being returned after the swap.
Related Issues
Resolves opensearch-project#20909
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.