BoundedChannel performance #104791
Unanswered
fabianoliver
asked this question in
Ideas
Replies: 1 comment
-
Based on necessity. If you have a correct implementation that fulfills the contract of the channel and provides demonstrably better performance / scalability, we'd welcome a PR. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It looks like all read/write operations on bounded channels use a shared lock.
I'd be curious as to how this implementation came to be - did any specific benchmarks suggest this was the most efficient approach? Or was this mostly a decision based on simplicity of implementation rather than performance?
My understanding was that channels in particular were rather optimised for performance-oriented scenarios. Intuitively, I was a bit surprised to see a locking strategy like that (but then again, never judge performance based on intuition ..)
Naively, I would have imagined bounded channels to be implemented via some form of circular buffer, for which quite many very efficient strategies exist that may do without locking, or with relatively limited locking (see eg the relatively popular disruptor pattern), and quite many more optimisations for single producer cases in particular.
If those weren't explored yet, is that something the BCL team would consider in the future?
Anecdotally, I'm just working on a message processing based application, and a prototype of a simple custom ringbuffer seemed to increase throughput (of the entire application that is) by around ~20% compared to bounded channels. Granted, I could cut a few corners that the BCL surely could not, and I very much wouldn't vouch for the correctness of a prototype whipped up in half an afternoon - but the gist for me seemed to be that there could potentially be significant performance gains to be had for unbounded channels.
Beta Was this translation helpful? Give feedback.
All reactions