Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

feat(restore): make the number of reader threads an option - #670

Open
Akayashuu wants to merge 1 commit into
rustic-rs:mainfrom
Akayashuu:feat/restore-reader-threads
Open

Akayashuu wants to merge 1 commit into
rustic-rs:mainfrom
Akayashuu:feat/restore-reader-threads

Conversation

@Akayashuu

Copy link
Copy Markdown
Contributor

Closes #654

restore_contents always read packs on a pool of 20 threads. On a slow link that keeps 20 large reads in flight, so a consumer that stops a restore by failing the next read waits for all of them, and the first byte is written late.

Changes

  • RestoreOptions gets reader_threads: Option<NonZeroUsize>, with --reader-threads <NUM> under the clap feature. None keeps today's 20.
  • restore_contents takes the RestoreOptions and builds its pool from that field. Passing the options instead of sparse and the count keeps it within clippy's argument limit.
  • The constant is renamed DEFAULT_READER_THREADS_NUM, since it is no longer a maximum.

NonZeroUsize rather than usize because rayon reads 0 as "one thread per CPU", which is not what a consumer asking for fewer readers means.

Test

test_restore_with_a_single_reader_thread in tests/integration/restore.rs backs up the test data, restores it with reader_threads(1) and compares every regular file with the source.

cargo +stable fmt --all -- --check, cargo +stable clippy --workspace --all-targets --all-features -- -D warnings and the restore integration tests pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the restore's reader thread count an option

1 participant