-
Notifications
You must be signed in to change notification settings - Fork 39
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
scx_rustland: reduce overhead by caching host topology #238
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
htejun
approved these changes
Apr 23, 2024
Byte-Lab
approved these changes
Apr 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but we should probably also make the Cpumask implementation more efficient. I'll work on that
In case you want to give it a try, this might help: #241 |
arighi
force-pushed
the
rustland-reduce-topology-overhead
branch
from
April 24, 2024 14:19
854fdb4
to
538232c
Compare
Introuce a TopologyMap object, represented as an array of arrays, where each inner array corresponds to a core containing its associated CPU IDs. This object can be used as a cache to facilitate efficient iteration over the entire host's topology. Example usage: let topo = Topology::new()?; let topo_map = TopologyMap::new(topo)?; for (core_id, core) in topo_map.iter().enumerate() { for cpu in core { println!("core={} cpu={}", core_id, cpu); } } Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Looking at perf top it seems that the scheduler can spend a significant amount of time iterating over the CPU topology/cpumask information, especially when the system is running a significant amount of tasks: 2.57% scx_rustland [.] <scx_utils::cpumask::CpumaskIntoIterator as core::iter::traits::iterator::Iterator>::next Considering that scx_rustland doesn't support CPU hotplugging yet (it requires a full restart to properly handle CPU hotplug events), we can completely avoid this overhead by caching a TopologyMap object at the beginning, when the scheduler starts, instead of constantly re-evaluating the CPU topology information. This allows to reduce the scheduler overhead by ~5% CPU utilization under heavy load conditions (from ~65% -> ~60%, according to top). Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
arighi
force-pushed
the
rustland-reduce-topology-overhead
branch
from
April 24, 2024 15:10
538232c
to
5302ff1
Compare
(meh... pushed the wrong branch, should be good now) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looking at
perf top
it seems that the scheduler can spend a significant amount of time in topology::Cache::span(), especially when the system is running a significant amount of tasks:5.46% scx_rustland [.] scx_utils::topology::Cache::span
Considering that scx_rustland doesn't support CPU hotplugging yet (it requires a full restart to properly handle CPU hotplug events), we can completely avoid this overhead by caching the cores/CPUs mapping at the beginning, when the scheduler starts, instead of constantly re-evaluating the CPU topology information.
This allows to reduce the scheduler overhead by ~10% CPU utilization under heavy load conditions (from ~68% -> ~60%, according to
top
).