mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-12 00:42:05 +03:00
Optimize data directory backup migration via concurrent chunked copying
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
64eb393c37
commit
b3bc0225e5
1 changed files with 7 additions and 2 deletions
|
|
@ -585,9 +585,14 @@ fn migrate_data_dir(
|
|||
}
|
||||
|
||||
if !files_to_copy.is_empty() {
|
||||
let thread_count = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(4);
|
||||
let thread_count = std::thread::available_parallelism()
|
||||
.map(|n| n.get())
|
||||
.unwrap_or(4);
|
||||
let chunk_size = (files_to_copy.len() / thread_count).max(1);
|
||||
let chunks: Vec<_> = files_to_copy.chunks(chunk_size).map(|c| c.to_vec()).collect();
|
||||
let chunks: Vec<_> = files_to_copy
|
||||
.chunks(chunk_size)
|
||||
.map(|c| c.to_vec())
|
||||
.collect();
|
||||
|
||||
let mut handles = Vec::new();
|
||||
for chunk in chunks {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue