Skip to content

Issue #1377: automatic export lanes follow the GPU's measured share - #1579

Merged
emmertex merged 1 commit into
mainfrom
claude/project-thread-1en860-lanes
Nov 27, 2026
Merged

emmertex merged 1 commit into
mainfrom
claude/project-thread-1en860-lanes

Conversation

@emmertex

Copy link
Copy Markdown
Owner

Requested by Andrew · project thread

Part of #1377 (step 4). It's independent of #1561 and #1575.

Problem

The plan called for overlapping "CPU decode of photo N+1 with GPU render of photo N, with lane counts sized from the measured split instead of a fixed 8". The overlap is already there: a photo decodes before its GPU turn and encodes after it (render_pair), so lanes side by side keep both busy. The lane count, though, is fixed at half the cores (up to 12) whatever the work. When the GPU is the bottleneck, the extra lanes just wait for their turn, each holding a decoded original: 45 MP of float RGB is 540 MB. blwfish measured 4 lanes against 8 on his M4 Max at 2048 px: 5 % slower, but 40 % less peak memory.

Change

  • lcc_gpu::busy::hold (exposed as lcc_gpu::hold_busy_meter/busy_time, which do nothing in the browser) meters the GPU's busy time without resetting the total, so a batch can read the differences while the bench's own meter keeps working.
  • export::Queue gains a Split. With automatic lanes it meters the GPU over each stretch of twice the running photos, then sizes the lanes from the result (next_lane_limit):
    • one photo fewer while the GPU was busy ≥ 90 % of the stretch;
    • one more while it was busy < 70 %;
    • never fewer than 2 (one photo on the CPU while one renders) or more than the automatic count.
  • Lanes pick up the new limit as they finish photos, so a lowered limit never interrupts a photo already running.
  • Unchanged:
    • lanes set by hand (Test my machine, <PREFIX>_EXPORT_LANES) are used as given;
    • without a GPU the share is 0, so every lane runs, as before;
    • with <PREFIX>_PROFILE=1, each change is logged.

Not in this PR: raising lanes above the automatic count. The memory gate still caps them, and CPU-bound batches gain nothing from more (blwfish's 4-against-8 run).

How it was checked

  • cargo xtask ci --quick: all 16 steps pass.
  • lanes_follow_the_gpus_share_of_the_work checks the rule: down to 2 while saturated, back up to the automatic count while starved, unchanged in between, all lanes without a GPU, a NaN reading changes nothing, and 1 lane stays 1.
  • The export:: tests pass (128).
  • The effect on a real GPU: not measurable here, because this container's GPU is the same CPU cores. The comparison to run on blwfish's machine is peak memory and wall time of a 500-photo export, default against <PREFIX>_EXPORT_LANES=8.

Merging

  • Overlap: Issue #1377: full-size Bayer raws demosaic on the GPU #1575 (GPU demosaic) makes GPU-bound batches more likely, which is when this matters. The two don't touch the same code.
  • Existing edits and libraries: unchanged; only how many photos render at once changes.
  • Shared numbers taken: none.
  • New dependencies, unsafe, build scripts, network access, spawned processes, deleted files, CI or xtask gate changes: none.

Manual: platforms/performance.mdx, manual/agents-and-status.md. Release notes: docs/whats-new/ and docs/changelog/unreleased/ entries.


Generated by Claude Code

Step 4 of the export plan. The CPU already decodes and encodes a photo outside its GPU turn, so photos overlap;
what was fixed was how many: half the cores, up to 12. Now a batch with automatic lanes meters the GPU's busy
time (lcc_gpu::hold_busy_meter, no reset of the bench's meter) over each stretch of twice the photos running,
and runs one photo fewer while the GPU was busy 90 % of it or more (the extra photos only wait for it, each
holding a decoded original) and one more while it was under 70 %, between 2 and the automatic count. Lanes set
by hand (Test my machine, <PREFIX>_EXPORT_LANES) are unchanged; without a GPU every lane runs as before.

Manual: platforms/performance.mdx, manual/agents-and-status.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011VFDrfcYF2xSBoosZAu8dw
@emmertex emmertex self-assigned this Nov 27, 2026
@emmertex
emmertex merged commit 162215f into main Nov 27, 2026
8 checks passed
@emmertex
emmertex deleted the claude/project-thread-1en860-lanes branch November 27, 2026 22:00
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.

2 participants