Skip to content

Commit 15fca2d

Browse files
committed
compiletest: Run tests in their own thread to avoid blocking the scheduler
The calls to waitpid are interacting badly with the message passing that goes on between schedulers and causing us to have very little parallelism in the test suite. I don't fully understand the sequence of events that causes the problem here but clearly blocking on waitpid is something that a well-behaved task should not be doing. Unfortunately this adds quite a bit of overhead to each test: one thread, two tasks, three stacks, so there's a tradeoff. The time to execute run-pass on my 4-core machine goes from ~750s to ~300s.
1 parent 0d817ee commit 15fca2d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/compiletest/runtest.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@ use procsrv;
2020
use util;
2121
use util::logv;
2222

23+
use std::cell::Cell;
2324
use std::io;
2425
use std::os;
2526
use std::str;
27+
use std::task::{spawn_sched, SingleThreaded};
2628
use std::vec;
2729

2830
use extra::test::MetricMap;
2931

3032
pub fn run(config: config, testfile: ~str) {
31-
let mut _mm = MetricMap::new();
32-
run_metrics(config, testfile, &mut _mm);
33+
let config = Cell::new(config);
34+
let testfile = Cell::new(testfile);
35+
// FIXME #6436: Creating another thread to run the test because this
36+
// is going to call waitpid. The new scheduler has some strange
37+
// interaction between the blocking tasks and 'friend' schedulers
38+
// that destroys parallelism if we let normal schedulers block.
39+
// It should be possible to remove this spawn once std::run is
40+
// rewritten to be non-blocking.
41+
do spawn_sched(SingleThreaded) {
42+
let config = config.take();
43+
let testfile = testfile.take();
44+
let mut _mm = MetricMap::new();
45+
run_metrics(config, testfile, &mut _mm);
46+
}
3347
}
3448

3549
pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {

0 commit comments

Comments
 (0)