Skip to content

Conversation

@315157973
Copy link
Contributor

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

  • [ x ] doc-not-needed
    It is a internal class

@315157973 315157973 self-assigned this Jun 5, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 5, 2022
Copy link
Contributor

@merlimat merlimat left a 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.

@merlimat merlimat added this to the 2.11.0 milestone Jun 5, 2022
@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Jun 5, 2022
@merlimat merlimat merged commit 522afcf into apache:master Jun 7, 2022
merlimat pushed a commit that referenced this pull request Jul 12, 2022
* Support shrinkage in TripleLongPriorityQueue

* Add unit test

* Remove unused code

* style

* Address comments
merlimat pushed a commit that referenced this pull request Jul 12, 2022
* Support shrinkage in TripleLongPriorityQueue

* Add unit test

* Remove unused code

* style

* Address comments
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jul 13, 2022
* Support shrinkage in TripleLongPriorityQueue

* Add unit test

* Remove unused code

* style

* Address comments

(cherry picked from commit 88b10e0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants