Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Improve channels (across go routines) performance for certain scenarios #11506

Closed
dumblob opened this issue Sep 15, 2021 · 0 comments
Closed
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Comments

@dumblob
Copy link
Contributor

dumblob commented Sep 15, 2021

Currently channels (vlib/sync/channels.v) use a ring buffer with smart locking optimizations (I didn't yet find any time to check correctness of these considering the C memory model as described in https://research.swtch.com/mm - there might be some fences needed or not... IDK - but so far it seems to do what's expected in usual setups). Thanks @UweKrueger for all the hard work!

The performance is acceptable and the ring buffer itself doesn't seem to be the main bottle neck for usual scenarios using (very) small buffer capacities. For others (incl. networking, "message passing", actor frameworks, etc.) this will become a limitation though.

One potential solution could be the use of a "BipBuffer" (aka "virtual ring buffer") as described in https://www.codeproject.com/Articles/3479/The-Bip-Buffer-The-Circular-Buffer-with-a-Twist and http://vrb.sourceforge.net/ and https://ferrous-systems.com/blog/lock-free-ring-buffer/ and https://github.com/jamesmunns/bbqueue and others. Except for the main property of being contiguous, another advantage is, that BipBuffer should allow for even more locking optimizations.

Those of you needing some more performance from channels, feel free to give it a try!

@UweKrueger @medvednikov @spytheman @cristian-ilies-vasile @JalonSolov @penguindark and many others...

@dumblob dumblob added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Sep 15, 2021
@vlang vlang locked and limited conversation to collaborators Sep 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants