Skip to content

Commit 19901d4

Browse files
alexcrichtonMark-Simulacrum
authored andcommitted
Allow usage of all cores
Get those sweet parallelism wins!
1 parent b37a88c commit 19901d4

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/bin/rustc-fake.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,16 @@ fn exec(cmd: &mut Command) -> ! {
3737
fn raise_priority() {
3838
extern crate libc;
3939

40-
use std::io;
41-
use std::mem;
42-
4340
unsafe {
44-
// Pin ourselves to just one core in case we're running on a multicore
45-
// system to try to normalize our results a bit
46-
let mut set: libc::cpu_set_t = mem::zeroed();
47-
libc::CPU_ZERO(&mut set);
48-
libc::CPU_SET(0, &mut set);
49-
let r = libc::sched_setaffinity(libc::getpid(),
50-
mem::size_of_val(&set),
51-
&set);
52-
if r != 0 {
53-
panic!("failed to set affinity: {}", io::Error::last_os_error());
54-
}
55-
5641
// Try to reduce jitter in wall time by increasing our priority to the
5742
// maximum
58-
let r = libc::setpriority(libc::PRIO_PROCESS as _,
59-
libc::getpid() as libc::id_t,
60-
-20);
61-
if r != 0 {
62-
// this requires elevated privileges, so just ignore if this fails,
63-
// and hope we've got elevated privileges on the actual perf bot.
43+
for i in (1..21).rev() {
44+
let r = libc::setpriority(libc::PRIO_PROCESS as _,
45+
libc::getpid() as libc::id_t,
46+
-i);
47+
if r == 0 {
48+
break
49+
}
6450
}
6551
}
6652
}

0 commit comments

Comments
 (0)