Repository navigation
#879: cap GPU frames in flight during export - #1184
Merged
h-a-n-a-s-h-i merged 3 commits intoOct 13, 2026
Merged
Conversation
With a GPU accelerator every frame of a batch rendered in parallel, each holding its own working textures, so a 30-frame 1080p batch could take the whole card (20+ GB on an RTX 3090) and run shared-memory GPUs out of memory. Cx::frames now renders GPU frames in consecutive chunks of 3 (EFFECTCRAFT_GPU_INFLIGHT overrides it), the same cap as the export scheduler in storytold#898; output order and the CPU path are unchanged. Fixes storytold#879
Three frames at once still filled an 8 GB card on the storytold#879 project at 1080p (7.9 GB, the same as no cap); one frame peaked at 6.3 GB and two at 7.0 to 7.8 GB. One matches how the export scheduler in storytold#898 renders image sequences (one GPU worker, synchronous readback). EFFECTCRAFT_GPU_INFLIGHT still raises it.
…#879 review) - The cap applied whenever an accelerator was attached, so Software Only projects (which render on the CPU) rendered one frame at a time. It now needs the project's GPU acceleration too, as storytold#898 gates it. - Only the render is capped: each window of max(cap, threads) frames renders in chunks of the cap, then encodes in parallel, holding at most one window of images. - An invalid EFFECTCRAFT_GPU_INFLIGHT (0, negative, not a number, too large) logs a warning before using the default. - The default stays one frame: the GPU backend reports no free or total device memory portably, so it is not sized from VRAM.
Member
|
Merged. Thank you for the contribution, @MatejKozlovsky! It landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #879
Problem
During export,
Cx::frames(crates/export/src/pipeline.rs) rendered every frame of a batch at once (ks.into_par_iter()). With a GPU accelerator, each frame in flight holds its own working textures. On the #879 project (142 shape and text layers, 1080p), a 30-frame--gpuexport used about 20 GB above idle on an RTX 3090 (23.9 GB total). On an 8 GB card it filled the card, and main quietly rendered every frame on the CPU: its PNGs are byte-identical to a CPU render. On shared-memory GPUs (the Intel and AMD reports in #879) the same burst can take the process down instead.Change
max(cap, threads). Each window renders in chunks of the cap, then encodes in parallel, so at most one window of images is held in RAM.EFFECTCRAFT_GPU_INFLIGHT=N. An invalid value (0, negative, not a number, too large) logs a warning and uses the default.Interaction with #898
#898's export scheduler already renders through a single GPU worker on the GPUs it is tuned for (NVIDIA discrete, Apple silicon). On top of #898, this change only affects the
Plan::Parallel(Gpu)fallthrough: other vendors and the stock path. That is the path the #879 reporters (Intel, AMD) are on. Both PRs touchCx::frames. I'm happy to rebase whichever lands second.Tests
New unit tests in
pipeline::tests:Errframe doesn't hold up the rest, and a panicking frame propagates once with the next batch runningEFFECTCRAFT_GPU_INFLIGHToverride, including overflowResults:
cargo fmt --all -- --check,cargo clippy -p effectcraft-export --all-targets -- -D warningsandcargo test -p effectcraft-exportall pass (81 tests).cargo xtask cion Windows: 103 passed, 1 failed. The failure iseffectcraft-clirender_out_is_relative_to_the_working_directory, a\\?\verbatim-path mismatch from canonicalisation on Windows (left: C:\...\out\d.gif,right: \\?\C:\...\out\d.gif). It fails the same way on main 9efe753, so it's pre-existing and unrelated to this change.pipeline.rsis unchanged upstream.Measurements
Final head, test PC with an RTX 3090 (24 GB, idle about 1.25 GB). Each value is the median of 3 runs of a 30-frame export, PNG.
--gpu(142 shape and text layers)--gpuOutput parity (PNG md5, all 30 frames):
RAYON_NUM_THREADS=1(main's GPU output) and stable across runs. With default threads, main's PNGs are byte-identical to its Software Only render. So even on 24 GB, main quietly falls back to the CPU for this project once the card fills, while this PR renders on the GPU.Earlier runs at one frame in flight, before the review fixes, which don't change the render cap. 30-frame 1080p
--gpuexport of the #879 project: