-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Avoid some uses of ConcurrentLinkedQueue.size() in SharedBlobCacheService #128119
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
Avoid some uses of ConcurrentLinkedQueue.size() in SharedBlobCacheService #128119
Conversation
SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.
Pinging @elastic/es-distributed-indexing (Team:Distributed Indexing) |
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
Hi @cbuescher, I've created a changelog YAML for you. |
@elasticmachine update branch |
There are no new commits on the base branch. |
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.
Great catch Christoph ! 🚀
Should we also add a warning for the freeRegionCount
method not being constant time? Either javadoc or @Deprecated
or both?
Good call, the method is already package private and from the current doc comment should have been only used by tests. I'll remove that doc and make it even clearer that this isn't constant-time. |
@tlrx Andrei just made a good point about whether it makes sense to backport this change to 9.0 and 8.19. If you don't disagree for some reason I would do that later today. Let me know if you think otherwise. |
All good for me to backport. |
…vice (elastic#128119) SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.
Backport PR to 9.0 and 8.19: #128194 |
…vice (#128119) (#128194) SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.
…vice (elastic#128119) (elastic#128194) SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.
…vice (#128119) (#128194) (#128203) SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.
SharedBlobCacheService keeps track of the free regions in a ConcurrentLinkedQueue. We use its "size()" method in three places outside of tests but unfortunately this is not a constant time operation because of the asynchronous nature of this queue. This change removes two of the uses where we only check if the queue is empty by calling the "isEmpty()" method instead.