Skip to content
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

Reduce memory used in ClientCnx for pending lookups #4104

Merged
merged 2 commits into from
Apr 23, 2019

Conversation

merlimat
Copy link
Contributor

Motivation

Currently, each ClientCnx has a blocking queue for the max number of pending lookup requests. By default that ends up using an array of 45K objects. When a single process handles many connections (eg: broker or proxy), that will end up using 200K per connection just for this.

Modifications

Instead of using the fixed array size, use semaphore and a ConcurrentLinkedQueue

@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Apr 22, 2019
@merlimat merlimat added this to the 2.4.0 milestone Apr 22, 2019
@merlimat merlimat self-assigned this Apr 22, 2019
this.waitingLookupRequests = Queues
.newArrayBlockingQueue((conf.getMaxLookupRequest() - conf.getConcurrentLookupRequest()));
this.pendingLookupRequestSemaphore = new Semaphore(conf.getConcurrentLookupRequest(), false);
this.maxLookupRequestSemaphore = new Semaphore(conf.getMaxLookupRequest(), false);
Copy link
Contributor

Choose a reason for hiding this comment

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

conf.getMaxLookupRequest() - conf.getConcurrentLookupRequest()

@jiazhai jiazhai merged commit 3f779a4 into apache:master Apr 23, 2019
MarvinCai added a commit to MarvinCai/pulsar that referenced this pull request May 16, 2019
Update to use ConcurrentLinkedQueue and same semaphore to limit concurrent request for BatchLookRequest.
It share same semaphore with normal lookup request.
MarvinCai added a commit to MarvinCai/pulsar that referenced this pull request May 17, 2019
Update to use ConcurrentLinkedQueue and same semaphore to limit concurrent request for BatchLookRequest.
It share same semaphore with normal lookup request.
@merlimat merlimat deleted the client-cnx-mem branch June 25, 2019 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants