mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Don't spawn a new thread for fresh jobs
The overhead in doing so is often much higher than the actual time it takes to execute the job
This commit is contained in:
parent
1fc37008e1
commit
0c5f6f012e
@ -880,10 +880,17 @@ impl<'cfg> DrainState<'cfg> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match fresh {
|
match fresh {
|
||||||
Freshness::Fresh => self.timings.add_fresh(),
|
Freshness::Fresh => {
|
||||||
Freshness::Dirty => self.timings.add_dirty(),
|
self.timings.add_fresh();
|
||||||
|
// Running a fresh job on the same thread is often much faster than spawning a new
|
||||||
|
// thread to run the job.
|
||||||
|
doit();
|
||||||
|
}
|
||||||
|
Freshness::Dirty => {
|
||||||
|
self.timings.add_dirty();
|
||||||
|
scope.spawn(move |_| doit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scope.spawn(move |_| doit());
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user