Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Recycle nodes in unbounded channels #80

Closed
ghost opened this issue Jul 28, 2018 · 1 comment
Closed

Recycle nodes in unbounded channels #80

ghost opened this issue Jul 28, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 28, 2018

In order to reduce the rate of allocation/deallocation in unbounded channels, we should keep some number of removed nodes for quick recycling.

Here's an idea for how we might implement this:

  • Each unbounded channel keeps a lock-free stack of removed nodes.

  • If a receive operation removes a node, we should push it onto the stack. However, if the stack is larger than the live queue, that means we're wasting a lot of memory. In such cases we should deallocate the removed node as well as deallocate one node from the stack.

  • If a send operation needs a new node, it should first try popping one from the stack. And if the stack is empty, just allocate a fresh node.

@ghost
Copy link
Author

ghost commented Nov 5, 2018

This is a pretty advanced optimization with questionable benefits. I'm not sure whether it's worth it anymore.

@ghost ghost closed this as completed Nov 5, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

0 participants