Hey,
I am using channels on my rust code which behind the scene uses stream::Packet that uses sync::mpsc::spsc_queue.
I notice that my application reaches peaks on the queue size and the memory usage is not dropped after those peaks even though I see that the bound option is set to 128 elements:
|
spsc::Queue::with_additions( |
.
I looked at the spsc_queue.rs code and I notice that the cached_nodes is not increased when adding an element to the cache:
|
self.consumer.cached_nodes.store(cached_nodes, Ordering::Relaxed); |
I tried locally the following change and it fixed the problem:
- self.consumer.cached_nodes.store(cached_nodes, Ordering::Relaxed);
+ self.consumer.cached_nodes.store(cached_nodes + 1, Ordering::Relaxed);
I am not sure if this is a right fix or whether my analysis is correct (maybe I got it all wrong?). Please let me know what you think or if there is anything else I might be missing?
Thanks.
Hey,
I am using channels on my rust code which behind the scene uses
stream::Packetthat usessync::mpsc::spsc_queue.I notice that my application reaches peaks on the queue size and the memory usage is not dropped after those peaks even though I see that the
boundoption is set to 128 elements:rust/library/std/src/sync/mpsc/stream.rs
Line 70 in fe5b13d
I looked at the
spsc_queue.rscode and I notice that thecached_nodesis not increased when adding an element to the cache:rust/library/std/src/sync/mpsc/spsc_queue.rs
Line 180 in fe5b13d
I tried locally the following change and it fixed the problem:
I am not sure if this is a right fix or whether my analysis is correct (maybe I got it all wrong?). Please let me know what you think or if there is anything else I might be missing?
Thanks.