Skip to content

Commit 7d76bc3

Browse files
committed
Fix multi-thread affinity
This makes multi-threaded benchmarks be spread across CPUs, instead of pinning the main thread to CPU 0 and having all threads inherit the main thread's affinity.
1 parent b932cdd commit 7d76bc3

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Versioning](http://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- Multi-threaded benchmarks being spread across CPUs, instead of pinning the
14+
main thread to CPU 0 and having all threads inherit the main thread's
15+
affinity.
16+
1117
## [0.1.1] - 2023-10-25
1218

1319
### Fixed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ divan-macros = { version = "0.1.1", path = "macros" }
1717

1818
clap = { version = "4", default-features = false, features = ["std", "env"] }
1919
condtype = "1.3"
20-
core_affinity = { version = "0.8", default-features = false }
2120
regex = { package = "regex-lite", version = "0.1", default-features = false, features = ["std", "string"] }
2221

2322
[target.'cfg(not(any(windows, target_os = "linux", target_os = "android")))'.dependencies]

src/divan.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,6 @@ impl Divan {
129129
// Sorting is after filtering to compare fewer elements.
130130
EntryTree::sort_by_attr(&mut tree, self.sorting_attr, self.reverse_sort);
131131

132-
if action.is_bench() {
133-
// Try pinning this thread's execution to the first CPU core to
134-
// help reduce variance from scheduling.
135-
if let Some(&[core_id, ..]) = core_affinity::get_core_ids().as_deref() {
136-
if core_affinity::set_for_current(core_id) {
137-
eprintln!("Pinned thread to core {}", core_id.id);
138-
};
139-
}
140-
}
141-
142132
let timer = match self.timer {
143133
TimerKind::Os => Timer::Os,
144134

0 commit comments

Comments
 (0)