Add max_concurrent_captures to cap and rotate simultaneous peak captures - #66
Draft
HoneyHazard wants to merge 1 commit into
Draft
Add max_concurrent_captures to cap and rotate simultaneous peak captures#66HoneyHazard wants to merge 1 commit into
HoneyHazard wants to merge 1 commit into
Conversation
Each node wiremix monitors for peak levels gets its own dedicated PipeWire capture stream (wirehose/stream.rs::capture_node). Every one of those is a real client object the session manager has to track and policy-link, and that cost scales with how many exist at once - not with anything CPU-throttleable, since it's driven by stream count, not per-quantum processing. lazy_capture already limits this to on-screen nodes, but on views where many nodes are visible simultaneously (a busy Output Devices tab, a tall terminal), that alone doesn't bound the concurrent stream count. Adds max_concurrent_captures: Option<usize> (unset = current unbounded behavior). When set and more nodes are eligible for capture than the cap allows, which ones are actually captured rotates on a fixed 3s interval (deliberately much slower than render cadence - rotating every frame would create more stream churn than not capping at all) so every eligible node eventually gets sampled rather than whichever ones happened to become eligible first holding their slot indefinitely. Meters for nodes outside the active window keep showing their last captured value until their next turn, rather than resetting to zero. The cap is enforced as a hard invariant directly in start_capture() (not just in the rotation logic), so it can never be transiently exceeded even if several nodes become eligible at once before the next rotation tick runs. Verified live against the real PipeWire graph (not just unit tests): with --max-concurrent-captures 2, `pw-dump` showed exactly 2 wiremix-capture streams at any moment, and the actual target node IDs fully changed after the 3s interval elapsed - confirming both the cap and the rotation are real, not just passing in isolation. Tested: cargo test (148/148, including 4 new tests covering the cap being enforced by start_capture, rotation respecting the cap, the active window actually advancing between rotations, and the no-op case where fewer nodes are eligible than the cap), cargo fmt --check / cargo clippy -- -D warnings / cargo doc (matching wiremix's CI) all clean.
HoneyHazard
force-pushed
the
max-concurrent-captures
branch
from
August 6, 2026 10:28
dec5735 to
c526017
Compare
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.
That being said, I hope these can be helpful and useful additions that users could appreciate.
Each node wiremix monitors for peak levels gets its own dedicated PipeWire capture stream (
wirehose/stream.rs::capture_node). Every one of those is a real client object the session manager has to track and policy-link, and that cost scales with how many exist at once - not with anything CPU-throttleable, since it's driven by stream count, not per-quantum processing.lazy_capturealready limits this to on-screen nodes, but on views where many nodes are visible simultaneously (a busy Output Devices tab, a tall terminal), that alone doesn't bound the concurrent stream count.Adds
max_concurrent_captures: Option<usize>(unset = current unbounded behavior):start_capture()(not just in the rotation logic), so it can never be transiently exceeded even if several nodes become eligible at once before the next rotation tick runs.New config key (optional, no-op when unset):
Also available as
--max-concurrent-captures <COUNT>on the command line.Verified live against the real PipeWire graph, not just unit tests: with
--max-concurrent-captures 2,pw-dumpshowed exactly 2wiremix-capturestreams at any moment, and the actual target node IDs fully changed after the 3s interval elapsed - confirming both the cap and the rotation are real, not just passing in isolation.Tested:
cargo test: 148/148 passing, including 4 new tests covering the cap being enforced bystart_capture, rotation respecting the cap, the active window actually advancing between rotations, and the no-op case where fewer nodes are eligible than the capcargo fmt --check/cargo clippy -- -D warnings/cargo doc(matching this repo's CI): all cleanDrafted with AI assistance (Claude); reviewed by me before opening. Left as a draft while I finish going through it - not requesting review yet.