Skip to content

Unpack slots: a bounded pool of extractions instead of one global unpack lock - #735

Merged
xbmc4lyfe merged 1 commit into
mainfrom
unpack-slots
Nov 27, 2026
Merged

xbmc4lyfe merged 1 commit into
mainfrom
unpack-slots

Conversation

@xbmc4lyfe

@xbmc4lyfe xbmc4lyfe commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

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:

Tests

  • New unit tests (rust/src/parchecker/live_trust_tests.rs): the end repair certifies a file rebuilt ahead once; the lost slice is rebuilt with the last article, before any repair call; a corrupt write after the rebuild is caught at completion; no re-read in an already-completed file; the volume being written gets the rebuilt range; a failed recheck turns the full check back on; forged FileDesc.
  • Four existing tests counted only the repair call's slices. They now also count the slices rebuilt ahead.
  • New scenario: 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_bytes and repair_available_targets_with_files_and_hashes_now. A new test, a_live_repair_reads_nothing_back, checks io_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)

  • Farm x86_64: 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).
  • Farm arm64: cargo_exit=0 (rustyget-arm-a), daemon_exit=0, 433 / 433 scenarios passed.
  • macOS: not required, since there is no platform-specific code. A laptop cargo test --tests run at an early head also passed.
  • Earlier heads, 37013fa: two full-suite runs each failed one unrelated test because the shared live PAR pool ran out. The fixture now uses a private pool (5f3ff80).

Reviews

  • One clean-room review of the first commit: G2G. Its note 1 is fixed.
  • Delta reviews:
    • End-repair re-entry: NOT G2G, then fixed and G2G.
    • The zero re-read test was vacuous on the decode-ahead path: NOT G2G, then fixed and G2G.
    • The private-pool fixture: G2G.

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).

  • Deb rustyget_0.1.0+git20261126234642.68492e0a_amd64.deb, sha256 fb8f7ee71c5a77b35fd607e667e284f8096a83358714f2bd5527cad5f192ffe1.
  • The running exe is bc0059df, which is the installed rustyget-default.
  • Health: the same pid for 2 min, NRestarts 0, 11-18 MB/s, no crash markers.
  • Evidence: server:~/rgtest/nya-deploy-prmb-68492e0a-20261126-235359Z.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gVnyENvoEAe3vGwUYQ

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T00:43:51.749252Z e00226f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread rust/src/postproc.rs
Comment on lines 5493 to +5495
on_wait: Some(&|waiting| {
session_parked.store(waiting, Ordering::Release);
self.set_waiting(waiting);
self.session_wait(host, waiting);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread rust/src/prepost.rs
Comment on lines +1928 to +1929
let starting = unpacking.saturating_sub(crate::unpackslots::post_users());
!crate::unpackslots::room_for_finished(starting)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

xbmc4lyfe added a commit that referenced this pull request Nov 26, 2026
…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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread rust/src/livefeed.rs
Comment on lines +170 to 171
self.own = feed.writes();
(self.on_wait)(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

xbmc4lyfe added a commit that referenced this pull request Nov 26, 2026
…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
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Local validation (Actions unavailable) on head 6a3c8fd (head may have moved since; #735 was later rebased).

  • macOS m5air: cargo test PASS (1595 passed, 0 failed). just test-daemon FAIL on directunpacksimple (timeout waiting for RelDUS in history); reproduced on a rerun, known m5air wrapper issue, label it so, not a confirmed Unpack slots: a bounded pool of extractions instead of one global unpack lock #735 defect.
  • Linux arm64 (OrbStack, m4air): cargo test PASS (1703 passed), test-daemon PASS.
  • Full dupefallback harness: not recorded.
    Raw logs: ~/rustyget-requests/macval/735-6a3c8fd8/

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread rust/src/prepost.rs
Comment on lines +2626 to +2627
// (direct unpack waits for an unpack slot itself, see `unpackslots`)
if act != 1 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

xbmc4lyfe added a commit that referenced this pull request Nov 26, 2026
…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
…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
@xbmc4lyfe
xbmc4lyfe merged commit e00226f into main Nov 27, 2026
0 of 5 checks passed
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Merged as the locally signed squash e00226f (fast-forward of main from f1be381; GitHub verified). Deployed on 6790 as a744b528, whose tree is identical.

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.

1 participant