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

Share memory between channels #80

Open
gavin-norman-sociomantic opened this issue Nov 20, 2018 · 1 comment
Open

Share memory between channels #80

gavin-norman-sociomantic opened this issue Nov 20, 2018 · 1 comment

Comments

@gavin-norman-sociomantic
Copy link

gavin-norman-sociomantic commented Nov 20, 2018

(AKA "Kombischlange".)

At present, there is a very large overhead per channel: a large, fixed-size, in-memory queue is allocated, even though most of the channels are empty most of the time. It should be possible to find a way to minimise this unused memory.

@gavin-norman-sociomantic
Copy link
Author

One proposal for a system with greatly reduced per-channel overhead would be to use a shared memory pool, rather than one per channel. This could work something like the following:

  • For each channel, a queue of pointers to records is maintained.
  • When a record arrives, it is copied into a malloced buffer.
  • A pointer to the record's buffer is pushed to that channel's queue.
  • When a record is popped from memory, the buffer is simply freed and the pointer removed from the per-channel queue.

The per-channel queue of pointers has a limited size, both in terms of the number of items it may contain and in terms of the combined size in memory of the pointed-to records. In this way, the overhead per channel is reduced from a chunk of memory to store the actual records to a chunk of memory used to store a list of pointers to records, which could be significantly smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant