Skip to content

Reduce overhead in blob cache service get #96399

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

Merged

Conversation

henningandersen
Copy link
Contributor

Avoid the use of KeyedLock, which has a high overhead for uncontended locks. Reduce granularity of lock during #get to the actual region.

Relates #96372

Avoid the use of KeyedLock, which has a high overhead for uncontended locks.
Reduce granularity of lock during #get to the actual region.

Relates elastic#96372
@elasticsearchmachine
Copy link
Collaborator

Hi @henningandersen, I've created a changelog YAML for you.

if (entry.chunk.sharedBytesPos == -1) {
synchronized (entry.chunk) {
if (entry.chunk.sharedBytesPos == -1) {
if (keyMapping.get(regionKey) != entry) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also assign -2 to sharedBytesPos in this case instead. I think it does not really matter, we expect near no contention here.

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, hard to see how this wouldn't be a considerable win performance wise. Spent 20min thinking this through as well and couldn't find a safety issue with the change that wouldn't have been here already :)

@henningandersen henningandersen marked this pull request as ready for review May 29, 2023 08:13
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label May 29, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM :) Thanks Henning!

}
if (Assertions.ENABLED) {
Copy link
Contributor

@original-brownbear original-brownbear May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: maybe move this kind of assertion to a separate method (that can just include the next assertion below) to save a little on method size here? (probably not too relevant but also makes the method easier to read IMO)

@henningandersen
Copy link
Contributor Author

Thanks Armin!

@henningandersen henningandersen merged commit 856a244 into elastic:main May 31, 2023
henningandersen added a commit to henningandersen/elasticsearch that referenced this pull request May 31, 2023
In racy evict cases, assertions in blob cache did not hold, adapted test
and added fixes.

Relates elastic#96399
henningandersen added a commit that referenced this pull request Jun 1, 2023
In racy evict cases, assertions in blob cache did not hold, adapted test
and added fixes.

Relates #96399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >enhancement Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants