Repository navigation
Conversation
…alf of room each At the default thread count (one per core) a 32-core host started 32 LZMA2 block workers, leaving each 47 MiB of the 2 GiB budget in flight, less than one 64 MiB -mx5 block. Idle workers drew later blocks' packed bytes into the budget until the started blocks could not hand out their output, and the run decoded about one block at a time: slower than -mt16. plan() now also caps the workers so each keeps 1.5 blocks (six windows) in flight: 18 at -mx5 and 4 at -mx9 with 2 GiB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Prybar reported that after #318, extracting a 7z made of LZMA2 blocks at the default thread count was much slower than
-mt8on a 32-core x86 host (15.7 s against 5.5 s; 7zz took 8.0 s).Root cause
With
threads: Nonethe 7z run uses one thread per core, so it asks for 32 LZMA2 block workers.lzma2_par::planlimited the workers only by their own cost (a third of the 2 GiB budget, which pays for 38 at-mx5), so all 32 started. That left 1.5 GiB in flight, about 47 MiB per worker, which is less than one 64 MiB block. Idle workers make read-ahead bounded by the budget alone (#318), so the reader drew later blocks' packed bytes into the budget until it was full. The blocks that had already started then had no room to hand out their output, and the run fell back to decoding about one block at a time.This only shows on archives whose packed bytes plus in-flight output pass the budget at full width: many blocks, data that compresses poorly. Mixed data that packs well (1.2 GB to 405 MB) and a 17-block set ran the same at every width.
Fix
plannow also limits the workers so that each one keeps 1.5 7-Zip blocks of the budget in flight (a block is four dictionary windows, and never less thanMIN_PIECE). At least one worker still starts whenever its cost fits. A block's packed bytes leave the budget as its decoder consumes them, so a piece's waiting input plus its output so far stays near one block, and the extra half block is headroom. With the default 2 GiB this means at most 18 workers at-mx5and 4 at-mx9. The limit applies to explicit-mtNtoo, which made-mt32fast again. Fewer threads than the limit behave as before.I tried a limit of two blocks per worker first (14 workers). It was measurably slower on the 2 GB set (7.2 s against 5.8–6.1 s at 16–24 workers), because 33 pieces then take three waves instead of two.
Tests:
plan_leaves_each_worker_room_for_its_block. It checks 32 cores with 2 GiB at-mx5(18 workers) and at-mx9(4), the threads-asked case, and the small-budget cases. It also sweeps threads, budgets and windows to check that each started worker has at least 1.5 blocks in flight and that the workers' cost stays within a third of the budget.tests/sevenzip_lzma2_threads.rs,sevenzip_extract,sevenzip_print,sevenzip_method_namesand thelzma2_parunit tests.Updated
docs/7z-extract.mdand theSevenZipLimits::lzma2_parallel_bytesdoc.Bench
Wall time in seconds for
zipfast x -y -q [-mtN]to local disk, median of 3. Before and after runs were interleaved. The7zcolumn is 7-Zip 23.017z xat its default threads.x86, rustyget-x86-c (Xeon Platinum 8581C, 32 vCPU, 62 GB, so a 2 GiB budget). Another user kept the load average at 5–10 during the runs. Archives made with
7z a -m0=lzma2 -mmt:mixed: 1.21 GB → 405 MB,-mx5(text, binaries, 220 MB random)hard: 1.15 GB base64 of random bytes → 920 MB,-mx5, 17 blockshard2: 2.10 GB base64 of random bytes → 1.69 GB,-mx5, 33 blocks (the regression)mixed9: themixedinput at-mx9On
hard2the default went from 1.57× the best explicit setting to within 5% of it (5.75 s at-mt32), and it now beats 7z. Nothing else moved.Before the fix, the
hard2sweep on the same host was: 8 → 9.7, 12 → 7.4, 14 → 7.2, 16 → 5.8–6.2, 20 → 5.9–6.1, 24 → 5.9–6.0, 32 → 8.6–10.4 s.I could not reproduce the slowdown on the mixed set: on quiet rustyget-x86-b the default took 1.67 s against 1.65 s at
-mt8. It also did not appear under 16 or 32 CPU-hog processes on x86-c.Apple M4 (10 cores, 32 GB, so a 2 GiB budget). The
mixed-style set here is 1.06 GB → 368 MB, made with7zz a -m0=lzma2 -mx5 -mmt. Median of 5 interleaved runs; other sessions' test runs kept the load average at 6–17, so single runs vary by up to 2×. At 10 threadsplanpicks the same workers before and after (the limit is 18), so the code path is unchanged and the differences are noise.🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gZ63jJDJGeNcamsGrj