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

Optimize shared data layout to avoid false sharing #3

Closed
HadrienG2 opened this issue Mar 7, 2017 · 5 comments
Closed

Optimize shared data layout to avoid false sharing #3

HadrienG2 opened this issue Mar 7, 2017 · 5 comments

Comments

@HadrienG2
Copy link
Owner

The current implementation has minimal memory overhead, but can exhibit false sharing, which reduces the performance of concurrent reads and writes more than necessary. A more careful data layout could prevent this.

@HadrienG2 HadrienG2 changed the title Investigate false sharing optimization Optimize shared data layout to avoid false sharing Mar 11, 2017
@HadrienG2
Copy link
Owner Author

So, what I want here is to align each buffer on a cache line boundary. The back-buffer index and the last buffer index can safely reside on the same cache line, because they are always accessed together.

Two tracks to explore, neither of which is currently available in stable or nightly Rust, are...

@mkpankov
Copy link

Using repr(align) to manually align structs on a 64-bytes boundary, which is a typical cache line size. Tracking issue for the repr(align) RFC is rust-lang/rust#33626.

It seems it's stable now.

@HadrienG2
Copy link
Owner Author

Indeed, and crossbeam-utils will introduce a sane version of CachePadded in their next release. Once they release that, it will probably be the right time to update triple-buffer.

@HadrienG2
Copy link
Owner Author

Crossbeam have pushed new releases last month, so I can investigate this now.

@HadrienG2
Copy link
Owner Author

Fixed in v3

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

No branches or pull requests

2 participants