-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support shrink for TripleLongPriorityQueue #15936
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
Conversation
merlimat
left a comment
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.
This is already a nice improvement (provided we assure the memory is released correctly :) ).
A further improvement could be to consider the priority queue as composed of "segments", where each segment is a ByteBuf. When the queue shrinks and the size goes below a segment threshold, we can just remove the buffer, without any resizing.
...-common/src/main/java/org/apache/pulsar/common/util/collections/TripleLongPriorityQueue.java
Outdated
Show resolved
Hide resolved
...-common/src/main/java/org/apache/pulsar/common/util/collections/TripleLongPriorityQueue.java
Outdated
Show resolved
Hide resolved
...-common/src/main/java/org/apache/pulsar/common/util/collections/TripleLongPriorityQueue.java
Outdated
Show resolved
Hide resolved
* Support shrinkage in TripleLongPriorityQueue * Add unit test * Remove unused code * style * Address comments
* Support shrinkage in TripleLongPriorityQueue * Add unit test * Remove unused code * style * Address comments
* Support shrinkage in TripleLongPriorityQueue * Add unit test * Remove unused code * style * Address comments (cherry picked from commit 88b10e0)
Motivation
Support shrinkage in TripleLongPriorityQueue. Avoid memory waste.
Modifications
When the actual memory usage is less than the threshold, scale down.
Since the thresholds for expansion and contraction may be the same, in order to avoid frequent expansion and contraction, a 10% buffer is reserved.
Verifying this change
Verify that it can shrink normally
Documentation
doc-not-neededIt is a internal class