Library scan: leave one core free at startup
The startup channel scan used available_parallelism() (every core), which could briefly peg the whole box on a cold/large library. Cap it at cores-1 so the machine stays responsive; the scan is disk-I/O-bound and runs as a background task, so one fewer thread costs little. Mirrors the headroom the fingerprint pass and thumbnail pool already leave. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5ffdb179f7
commit
015d03751c
1 changed files with 5 additions and 4 deletions
|
|
@ -224,10 +224,11 @@ pub fn scan_channels_with_cache(youtube_root: &Path, cache: Option<&Database>) -
|
|||
}
|
||||
}
|
||||
|
||||
let n_workers = std::thread::available_parallelism()
|
||||
.map(|n| n.get())
|
||||
.unwrap_or(4)
|
||||
.min(dirs.len().max(1));
|
||||
// Leave one core free so a cold/large scan doesn't peg every core and
|
||||
// make the box unresponsive — this runs as a background task and the scan
|
||||
// is mostly disk-I/O-bound anyway, so giving up one thread costs little.
|
||||
let cores = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(4);
|
||||
let n_workers = cores.saturating_sub(1).max(1).min(dirs.len().max(1));
|
||||
// Hand each worker its own Database handle via .clone() (Arc inside,
|
||||
// cheap). Workers without a cache get None.
|
||||
let cache_handle: Option<Database> = cache.cloned();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue