Skip to content

bound option on spsc_queue.rs seems to have no effect #98251

Description

@MeirShpilraien

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyC-bugCategory: This is a bug.S-candidate-for-closingStatus: This issue will be closed after a week or so unless objections are raised.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions