mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +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 {
|
||||
Freshness::Fresh => self.timings.add_fresh(),
|
||||
Freshness::Dirty => self.timings.add_dirty(),
|
||||
Freshness::Fresh => {
|
||||
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(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user