Repository navigation
Unpack slots: a bounded pool of extractions instead of one global unpack lock - #735
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 227899fff0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| on_wait: Some(&|waiting| { | ||
| session_parked.store(waiting, Ordering::Release); | ||
| self.set_waiting(waiting); | ||
| self.session_wait(host, waiting); |
There was a problem hiding this comment.
Reacquire the slot before polling a resumed RAR session
When a RAR session waits for a volume, this callback now releases its slot, but Driver::next_event_or_tick in progressive_unpack.rs resumes by calling session.poll_event before calling set_waiting(false)—the latter happens only after Poll::Ready. Consequently, processing the newly available volume runs without a slot, potentially alongside another extraction that acquired the released slot. With UnpackSlots=1, this defeats the promised serialization and can leave the resumed extraction waiting for a slot only after it has already done the extraction work. Reacquire admission before polling a session that was parked on a volume.
Useful? React with 👍 / 👎.
| let starting = unpacking.saturating_sub(crate::unpackslots::post_users()); | ||
| !crate::unpackslots::room_for_finished(starting) |
There was a problem hiding this comment.
Register queued post unpacks so their waiting time can age
On a busy queue with continuously waiting active direct extractions, room_for_finished keeps rejecting finished jobs here before they can reach unpackslots::acquire. Those jobs therefore never receive a waiter ticket or accumulate the waiting time used by aged, so the advertised promotion after 30 seconds cannot prevent their starvation. This affects both post-job selection and the unpack-stage gate that use this helper: completed downloads can remain queued indefinitely while newer downloads continue extracting. Preserve a pool waiter or equivalent aging state for finished jobs while this gate blocks them.
Useful? React with 👍 / 👎.
…ack lock (#735) One global unpack lock serialized every direct unpack, live extraction and post-processing unpack. On 6790 (about 1000 groups) a paused item's direct unpack held it while it waited for volumes: a new download's live extraction never started, a weak primary failed over and downloaded its backup whole (XB copy 02/05, X54), and finished jobs sat in PP_QUEUED. - unpackslots: up to UnpackSlots extractions at once (0 = min(4, CPUs/2)). Slots go to an active download first, then a finished job's unpack, then a paused or fleet-held download; oldest first within a class; a waiter moves up one class per 30 s waited. - An extraction holds its slot only while it extracts: direct unpack gives it back while it waits for a volume (RAR session on_wait, log-line waits, live 7z/ZIP sets on their own download's writes). - Direct unpack starts whatever else extracts (no has_active_unpack / PostStrategy check), except while another copy of the release extracts or passed the post gate. Past max(4, 2 x slots) sessions a warning is logged; nothing is stopped. - The post-processing unpack gate asks the pool for room. - A direct unpack waiting for a slot is Running, so the failover keep rule keeps a weak primary whose backup's video is confirmed. - Scenarios dupausedlive and failcont_alt25busy (both fail on main); unit tests for capacity, admission order, aging, classes. Real XB rerun X55 on 6790 (deploy 36fa42c5): SUCCESS/UNPACK, primary kept and continued from its alt, backup DownloadedSizeMB 0, mkv sha256 0fccd3f5... as expected. Working history: origin/backup/unpack-slots-4c648cf5 and origin/backup/unpack-slots-227899ff (reviewed head). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gVnyENvoEAe3vGwUYQ
227899f to
6a3c8fd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a3c8fd858
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.own = feed.writes(); | ||
| (self.on_wait)(true); |
There was a problem hiding this comment.
Preserve writes arriving before the idle snapshot
For live 7z/ZIP or split-file extraction, an article can arrive after the decoder reports no progress but before idle() snapshots feed.writes(). That write is then included in self.own, and the callback releases the slot despite new input already being available. If no further writes arrive, the comparison below never calls busy(), yet feed_members or join_live proceeds to decode or copy that input on its next iteration; their progress callback runs only afterward. With UnpackSlots=1, another extraction can acquire the released slot and run concurrently. Track the write generation from before the unsuccessful processing attempt, or reacquire admission before processing newly available input.
Useful? React with 👍 / 👎.
…ack lock (#735) One global unpack lock serialized every direct unpack, live extraction and post-processing unpack. On 6790 (about 1000 groups) a paused item's direct unpack held it while it waited for volumes: a new download's live extraction never started, a weak primary failed over and downloaded its backup whole (XB copy 02/05, X54), and finished jobs sat in PP_QUEUED. - unpackslots: up to UnpackSlots extractions at once (0 = min(4, CPUs/2)). Slots go to an active download first, then a finished job's unpack, then a paused or fleet-held download; oldest first within a class; a waiter moves up one class per 30 s waited. - An extraction holds its slot only while it extracts: direct unpack gives it back while it waits for a volume (RAR session on_wait, log-line waits, live 7z/ZIP sets on their own download's writes). - Direct unpack starts whatever else extracts (no has_active_unpack / PostStrategy check), except while another copy of the release extracts or passed the post gate. Past max(4, 2 x slots) sessions a warning is logged; nothing is stopped. - The post-processing unpack gate asks the pool for room. - A direct unpack waiting for a slot is Running, so the failover keep rule keeps a weak primary whose backup's video is confirmed. - Removes #734's prepost::stop_stalled_direct_unpacks and its yield marks: a waiting direct unpack holds no slot, so a paused download's live extraction is no longer stopped for a finished job's unpack. dupausedunpack now expects no stop (RelB unpacks, RelA keeps waiting). - Scenarios dupausedlive and failcont_alt25busy (both fail on main); unit tests for capacity, admission order, aging, classes. Real XB rerun X55 on 6790 (deploy 36fa42c5): SUCCESS/UNPACK, primary kept and continued from its alt, backup DownloadedSizeMB 0, mkv sha256 0fccd3f5... as expected. Working history: origin/backup/unpack-slots-4c648cf5 and origin/backup/unpack-slots-227899ff (reviewed head). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
6a3c8fd to
76f441a
Compare
|
Local validation (Actions unavailable) on head 6a3c8fd (head may have moved since; #735 was later rebased).
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76f441a78d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // (direct unpack waits for an unpack slot itself, see `unpackslots`) | ||
| if act != 1 { |
There was a problem hiding this comment.
Include post-processing split-file joins in slot admission
With UnpackSlots=1, a new direct unpack can now start while a finished job is joining split files. NzbgetRsUnpackController::join_splitted_files performs the join without acquiring a pool slot; only execute_unpack acquires one. Previously, the removed has_active_unpack check blocked direct unpack throughout the other job's Unpacking stage. The pool therefore sees an unused slot during the join and admits another extraction, exceeding the configured concurrency and allowing competing bulk disk I/O even when serialization is requested. Make post-processing joins acquire a slot before relying exclusively on the pool here.
Useful? React with 👍 / 👎.
…ack lock (#735) One global unpack lock serialized every direct unpack, live extraction and post-processing unpack. On 6790 (about 1000 groups) a paused item's direct unpack held it while it waited for volumes: a new download's live extraction never started, a weak primary failed over and downloaded its backup whole (XB copy 02/05, X54), and finished jobs sat in PP_QUEUED. - unpackslots: up to UnpackSlots extractions at once (0 = min(4, CPUs/2)). Slots go to an active download first, then a finished job's unpack, then a paused or fleet-held download; oldest first within a class; a waiter moves up one class per 30 s waited. - An extraction holds its slot only while it extracts: direct unpack gives it back while it waits for a volume (RAR session on_wait, log-line waits, live 7z/ZIP sets on their own download's writes). - Direct unpack starts whatever else extracts (no has_active_unpack / PostStrategy check), except while another copy of the release extracts or passed the post gate. Past max(4, 2 x slots) sessions a warning is logged; nothing is stopped. - The post-processing unpack gate asks the pool for room. - A direct unpack waiting for a slot is Running, so the failover keep rule keeps a weak primary whose backup's video is confirmed. - Removes #734's prepost::stop_stalled_direct_unpacks and its yield marks: a waiting direct unpack holds no slot, so a paused download's live extraction is no longer stopped for a finished job's unpack. dupausedunpack now expects no stop (RelB unpacks, RelA keeps waiting). - A direct unpack stop deletes the dead volumes it borrowed only when the download was deleted. A stop for a failure (password, damage, missing volume) or a failover hold leaves them for post-processing, so a download that goes on never fetches a dead volume twice (#734's rule, now for every stop path). - Scenarios dupausedlive and failcont_alt25busy (both fail on main); unit tests for capacity, admission order, aging, classes. Real XB rerun X55 on 6790 (deploy 36fa42c5): SUCCESS/UNPACK, primary kept and continued from its alt, backup DownloadedSizeMB 0, mkv sha256 0fccd3f5... as expected. Working history: origin/backup/unpack-slots-4c648cf5 and origin/backup/unpack-slots-227899ff (reviewed head). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
76f441a to
c236156
Compare
…ack lock (#735) One global unpack lock serialized every direct unpack, live extraction and post-processing unpack. On 6790 (about 1000 groups) a paused item's direct unpack held it while it waited for volumes: a new download's live extraction never started, a weak primary failed over and downloaded its backup whole (XB copy 02/05, X54), and finished jobs sat in PP_QUEUED. - unpackslots: up to UnpackSlots extractions at once (0 = min(4, CPUs/2)). Slots go to an active download first, then a finished job's unpack, then a paused or fleet-held download; oldest first within a class; a waiter moves up one class per 30 s waited. - An extraction holds its slot only while it extracts: direct unpack gives it back while it waits for a volume (RAR session on_wait, log-line waits, live 7z/ZIP sets on their own download's writes). - Direct unpack starts whatever else extracts (no has_active_unpack / PostStrategy check), except while another copy of the release extracts or passed the post gate. Past max(4, 2 x slots) sessions a warning is logged; nothing is stopped. - The post-processing unpack gate asks the pool for room. - A direct unpack waiting for a slot is Running, so the failover keep rule keeps a weak primary whose backup's video is confirmed. - Removes #734's prepost::stop_stalled_direct_unpacks and its yield marks: a waiting direct unpack holds no slot, so a paused download's live extraction is no longer stopped for a finished job's unpack. dupausedunpack now expects no stop (RelB unpacks, RelA keeps waiting). - A direct unpack stop deletes the dead volumes it borrowed only when the download was deleted. A stop for a failure (password, damage, missing volume) or a failover hold leaves them for post-processing, so a download that goes on never fetches a dead volume twice (#734's rule, now for every stop path). - Scenarios dupausedlive and failcont_alt25busy (both fail on main); unit tests for capacity, admission order, aging, classes. Real XB rerun X55 on 6790 (deploy 36fa42c5): SUCCESS/UNPACK, primary kept and continued from its alt, backup DownloadedSizeMB 0, mkv sha256 0fccd3f5... as expected. Working history: origin/backup/unpack-slots-4c648cf5 and origin/backup/unpack-slots-227899ff (reviewed head). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYUGuwLMB2hw7HQGbM
c236156 to
e00226f
Compare
Was stacked on #729, which is now merged (c4d4e79). Rebased onto main ba93ae1. par-rs is pinned to b60bfd1.
What
par-rs 6d0f005 -> b60bfd1 (main 1471b1f plus #140-#143), and RustyGet adopts what changed since cd1703f:
set_decode_ahead(true)when targets hold the verified bytes. The damaged slices are rebuilt, checked and written into their targets in the fold that verifies the last other slice. RustyGet takes them withtake_rebuilt_slicesafter every operation and after each drained fold. A volume still being written counts them as written (livewrite::rebuilt, only when par-rs wrote into its direct-write output), and the log says "rebuilt N damaged slice(s) ... ahead while downloading".on_range_replaced, those slices only). If the slice was overwritten since, it is diverged and the trusted check fails it, so the set is repaired from disk. If it cannot be re-verified at all, the whole-file check is turned back on. A slice rebuilt in a file that had already completed is final and is not read again.set_par2cmdline_block_matchingstays off, the default.mem_limit_bytesfrom config.Tests
livepardecodeahead.par-rs b60bfd1 (#143)
Re-pinned to par-rs b60bfd1: a live repair now credits the slices it rebuilds from the syndromes and no longer reads them back. There is no API change. RustyGet already uses trusted slices, slots planned for every downloaded recovery exponent (#729),
backfill_from_bytesandrepair_available_targets_with_files_and_hashes_now. A new test,a_live_repair_reads_nothing_back, checksio_stats(). When the repair call rebuilds the lost slices, the source, back-fill, recovery and target-verification reads are all 0. With decode-ahead, the only read is the deliberate re-check of exactly the rebuilt slices when their file completes.Validation (final head 5f3ff80, on main ba93ae1)
cargo_exit=0(rustyget-x86-a),daemon_exit=0, 432 / 433 scenarios passed. The one failure,fleetwide(timing: took=23.5, still queued), passed when run alone on the same head (cargo 0, daemon 0, 1/1).cargo_exit=0(rustyget-arm-a),daemon_exit=0, 433 / 433 scenarios passed.cargo test --testsrun at an early head also passed.Reviews
Deployment
Deployed on 6790 as 68492e0a, which is deploy-6790 32c5d3d9 plus this branch at 5aeb377 (the same code as 5f3ff80 before the rebase onto #734).
rustyget_0.1.0+git20261126234642.68492e0a_amd64.deb, sha256 fb8f7ee71c5a77b35fd607e667e284f8096a83358714f2bd5527cad5f192ffe1.rustyget-default.🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gVnyENvoEAe3vGwUYQ