-
-
Notifications
You must be signed in to change notification settings - Fork 927
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 usage of Transport #1470
Conversation
kombu/transport/virtual/base.py
Outdated
self.channel_id = self.connection._avail_channel_ids.pop() | ||
except IndexError: | ||
# Cast to a set for fast lookups, and keep stored as an array for lower memory usage. | ||
used_channel_ids = set(self.connection._used_channel_ids) |
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.
Maybe we should put this _used_channel_ids
stuff into its own method like it is in py-amqp?: https://github.com/celery/py-amqp/blob/6433be13199938f47bbc2826e6585e746baf4f9b/amqp/connection.py#L484-L492
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.
if that improves the codebase you could give it a try
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.
Ok, I went ahead and made this change: a439ada
also can you and your team please check the two open PR in pyamqp with this two PR in kombu & celery that nothing create any regression? I like your efforts very much, just being too cautious as it's holiday season coming. |
* reduce memory usage of Transport * fix flake8 errors * move channel_id login into _get_free_channel_id
While investigating a redis broker memory leak, I noticed the same issue as py-amqp's #377:
The array that's used to store available connection ids is taking up an unnecessary amount of memory (more than anything else while running celery), and it's making memory leaks worse.
This PR reduces the memory usage of the
Transport
by reversing that logic and turning_avail_channel_ids
into_used_channel_ids
. This will only store the channel ids that are currently used, which is almost always going to be a much smaller array.