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

rt: pad the task struct to avoid false sharing #5809

Merged
merged 1 commit into from Jun 21, 2023
Merged

Conversation

carllerche
Copy link
Member

This change pads the task struct to avoid false sharing. These structs can overlap cache lines without this alignment.

I avoided adding a CachePadded wrapper struct as I am not sure how the padded wrapper struct would impact the pointer stuff we do in the task harness (casting *Header to *Cell as well as the other pointer math).

I'm also not 100% sure what happens when you combine repr(C) with repr(align(n)) but I would guess (hope) it does the right thing.

Thoughts @Darksonn ?

As part of a larger scheduler refactor that I am working on, I have observed false sharing happened and confirmed the false sharing using perf c2c. Adding the padding here resolves the issue.

This change pads the task struct to avoid false sharing. It is possible
for these structs to overlap cache lines without this alignment.
@carllerche carllerche added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime T-performance Topic: performance and benchmarks labels Jun 21, 2023
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Jun 21, 2023
Copy link
Contributor

@Noah-Kennedy Noah-Kennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll stamp but I agree that we should have @Darksonn weigh in on the repr stuff.

@carllerche carllerche merged commit 2e62374 into master Jun 21, 2023
59 checks passed
@carllerche carllerche deleted the rt-task-cache-pad branch June 21, 2023 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime R-loom Run loom tests on this PR T-performance Topic: performance and benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants