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

cache miss on bounded crossbeam_channel::Receiver try_recv #1163

Open
boranby opened this issue Dec 20, 2024 · 3 comments
Open

cache miss on bounded crossbeam_channel::Receiver try_recv #1163

boranby opened this issue Dec 20, 2024 · 3 comments

Comments

@boranby
Copy link

boranby commented Dec 20, 2024

Hi,
I don't know whether this is an expected behavior of Atomics but when I run perf on my code I see that there are cache misses on try_recv call. I have a bounded queue, which has 8 senders and 1 receiver. In the sender sides, I couldn't find any notable miss, because of that I raise that issue for the receiver side.
My call:

loop {
    while let Ok(mut messages) = self.parsed_feed_receiver.try_recv() {
        ...
    }
        ...
}
perf stat cache_miss1 cache_miss2

There are other small misses but they are negligible compared to these 3 lines. If you can help to figure this out, I'll appreciate that. Thanks in advance.

@taiki-e
Copy link
Member

taiki-e commented Dec 20, 2024

It seems that the access to the field is causing loading from memory, so this patch may improve the situation: master...taiki-e/local-mark-bit

@boranby
Copy link
Author

boranby commented Dec 20, 2024

@taiki-e thanks for your quick response! I tried with the new branch, unfortunately it's still same.

@taiki-e
Copy link
Member

taiki-e commented Dec 20, 2024

Hmm, since mfence does the serialization, the previous cache should not be available for the load from r15+0x80 (i.e., self.tail), but I thought the load from r15+0x190 was the access to self.mark_bit, so I thought that could be omitted. However, normal offset of self.mark_bit is actually 0x108...

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

No branches or pull requests

2 participants