Repository navigation
perf(net): shrink group consumers without extra allocations - #7791
Conversation
Quest-Claim: 2eefa4b22b788d7b
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
|
Design change: reuse the existing (Written by GPT-6.1 Sol) |
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shared delivery state:
Consumer::track,arrived, andstale_countedcollapse into oneArc<Delivery>, keeping clones and frame readers on the same expiry flag while provenance and arrival still survive route adoption (adoption only swapscursor/expiry). - Lazy prefetch batch:
Prefetchbecomes a singleOption<Box<Batch>>, so the frame slots, cursor, and optional chains/fields/inflated tables share one allocation made by the firstpush;Batch::droppreserves the oldframes[pos..len]teardown. - Benchmark + docs:
SESSION_ALLOCS=1now printsgroup::Consumersize, and the bench README/module docs describe it. - Quest cleanup: the completed
group-consumer-sizequest is removed and its README andrelay-cpu-bisectlinks point at this PR.
Semantics check out: clone sharing, adoption, stale-count dedup, and the unsafe MaybeUninit drop ranges match the old behavior, and one Arc allocation still replaces the old one on the common path.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head 533ceafa0964b5de151032e8f85a5cb98c750792 against base 6647cda31ba061562c990eb5e7e2a980c9639eb6.
No actionable correctness findings in this diff. I checked that Delivery retains the original metadata and shared expiry flag through cloning, frame handoff, and route adoption; that lazy Batch allocation preserves refill, metadata, and MaybeUninit destruction invariants; and that the benchmark/reporting and quest changes agree with the implementation. Existing range, mixed segmented-frame, clone, refill-boundary, and partial-batch-drop tests were inspected.
Verification limits: GitHub-only static review. I did not run builds, tests, Miri, or benchmarks, and did not independently reproduce the performance figures. The current GitHub Check run was still in progress when inspected. State, head, prior reviews, and review threads were rechecked immediately before submission.
|
No actionable comments were generated in the recent review. WalkthroughPrefetch now stores frames and optional metadata in a lazily allocated batch. Consumer clones and expiry handlers share delivery metadata, including the flag used to count stale content once. The allocation report now includes the size of Merge Risk:
|
|
quest land watch: the merge queue removed this pull request at 533ceaf because its The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.
…are_reselects_even_when_the_source_type_is_unchanged
PASS [ 0.018s] (9499/9973) moq-video capture::portal::tests::missing_window_support_never_falls_back_to_a_screen
PASS [ 0.018s] (9500/9973) moq-video capture::settle::tests::a_static_resize_has_a_deadline_without_another_frame
PASS [ 0.018s] (9501/9973) moq-video capture::portal::tests::portal_versions_do_not_relax_mismatched_or_multiple_sources
PASS [ 0.018s] (9502/9973) moq-video capture::portal::tests::old_source_failure_cannot_clear_a_new_publications_grant
PASS [ 0.128s] (9503/9973) moq-uring udp::tests::a_oneshot_socket_takes_no_buffer_group_id
PASS [ 0.189s] (9504/9973) moq-uring udp::tests::a_failed_cancel_fails_the_next_turn
PASS [ 0.189s] (9505/9973) moq-uring udp::tests::a_failed_registration_returns_its_buffer_group_id
PASS [ 0.135s] (9506/9973) moq-uring udp::tests::a_failed_send_costs_only_its_packet
PASS [ 0.007s] (9507/9973) moq-uring udp::tests::a_recycled_buffer_does_not_mask_a_recorded_starvation
PASS [ 0.006s] (9508/9973) moq-uring udp::tests::a_zero_gro_size_is_no_stride
PASS [ 0.094s] (9509/9973) moq-video capture::portal::tests::cancelling_remote_open_keeps_the_validated_replacement
PASS [ 0.060s] (9510/9973) moq-video capture::portal::tests::diagnostic_output_does_not_expose_the_grant
PASS [ 0.031s] (9511/9973) moq-video capture::tests::source_labels_preserve_prefixed_window_ids
PASS [ 0.031s] (9512/9973) moq-video capture::tests::source_labels_preserve_prefixed_display_ids
PASS [ 0.006s] (9513/9973) moq-uring udp::tests::addr_roundtrip_v4
PASS [ 0.006s] (9514/9973) moq-uring udp::tests::addr_roundtrip_v6_keeps_scope_and_flow
PASS [ 0.036s] (9515/9973) moq-video capture::v4l2::tests::breaks_ties_toward_the_cheaper_format
PASS [ 0.052s] (9516/9973) moq-video capture::tests::source_labels_add_the_source_kind
PASS [ 0.054s] (9517/9973) moq-video capture::settle::tests::the_open_geometry_captures
PASS [ 0.055s] (9518/9973) moq-video capture::settle::tests::a_drag_restarts_the_wait_on_every_new_size
PASS [ 0.055s] (9519/9973) moq-video capture::settle::tests::a_drag_back_to_the_open_geometry_cancels
PASS [ 0.056s] (9520/9973) moq-video capture::settle::tests::a_change_ends_the_stream_once_it_holds
PASS [ 0.038s] (9521/9973) moq-video capture::v4l2::tests::enumeration_only_stops_on_einval
PASS [ 0.161s] (9522/9973) moq-video capture::mode::tests::modes_merge_sizes_and_sort_largest_and_fastest_first
PASS [ 0.040s] (9523/9973) moq-video capture::v4l2::tests::a_stepwise_frame_size_of_one_mode_is_reported_once
PASS [ 0.040s] (9524/9973) moq-video capture::v4l2::tests::a_stepwise_frame_size_is_reported_as_its_corners
PASS [ 0.040s] (9525/9973) moq-video capture::v4l2::tests::a_discrete_frame_size_is_reported_as_itself
PASS [ 0.009s] (9526/9973) moq-uring udp::tests::malformed_control_lengths_preserve_valid_prefix
PASS [ 0.063s] (9527/9973) moq-video capture::portal::tests::older_portals_can_omit_source_type
PASS [ 0.016s] (9528/9973) moq-video capture::v4l2::tests::fourcc_round_trips
PASS [ 0.015s] (9529/9973) moq-video capture::v4l2::tests::ignores_a_nearer_mode_the_pipeline_cannot_encode
FAIL [ 0.653s] (9530/9973) moq-transcode tests::live_multi_rung
stdout ───
running 1 test
test tests::live_multi_rung ... FAILED
failures:
failures:
tests::live_multi_rung
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 71 filtered out; finished in 0.64s
stderr ───
thread 'tests::live_multi_rung' (527051) panicked at rs/moq-transcode/src/lib.rs:556:44:
called `Result::unwrap()` on an `Err` value: Cancel
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Cancelling due to test failure: 23 tests still running
PASS [ 0.020s] (9531/9973) moq-video capture::v4l2::tests::equivalent_rates_deduplicate_and_sort_numerically
PASS [ 0.066s] (9532/9973) moq-video capture::tests::camera_selectors_name_their_backend
PASS [ 0.023s] (9533/9973) moq-video capture::v4l2::tests::keeps_a_valid_mode_when_another_probe_fails
PASS [ 0.018s] (9534/9973) moq-video capture::v4l2::tests::unencodable_frame_sizes_are_not_reported
PASS [ 0.020s] (9535/9973) moq-video capture::v4l2::tests::prefers_the_nearer_mode_over_the_cheaper_one
PASS [ 0.017s] (9536/9973) moq-video capture::wgc::tests::first_delivery_removes_the_startup_deadline
PASS [ 0.021s] (9537/9973) moq-video capture::v4l2::tests::no_usable_reply_is_none
PASS [ 0.017s] (9538/9973) moq-video capture::wgc::tests::new_frames_and_resume_keep_the_same_presentation_clock
PASS [ 0.016s] (9539/9973) moq-video capture::wgc::tests::notifications_are_retained_and_frames_coalesce
PASS [ 0.059s] (9540/9973) moq-uring udp::tests::a_raw_socket_sees_an_unreachable_send_fail
PASS [ 0.058s] (9541/9973) moq-uring udp::tests::a_stale_source_keeps_segmentation
PASS [ 0.061s] (9542/9973) moq-uring udp::tests::an_interrupted_enter_is_retried
PASS [ 0.068s] (9543/9973) moq-uring udp::tests::pool_gauges_sum_live_sockets
PASS [ 0.084s] (9544/9973) moq-video capture::v4l2::tests::stepwise_sizes_keep_even_interior_endpoints
PASS [ 0.086s] (9545/9973) moq-video capture::v4l2::tests::only_devices_offering_a_converted_format_are_cameras
PASS [ 0.085s] (9546/9973) moq-video capture::v4l2::tests::rates_preserve_fractional_and_sub_one_fps_intervals
PASS [ 0.086s] (9547/9973) moq-video capture::v4l2::tests::negotiation_selects_and_reapplies_the_format_accepting_the_requested_rate
PASS [ 0.085s] (9548/9973) moq-video capture::v4l2::tests::stepwise_bounds_match_the_enumerated_grid
PASS [ 0.088s] (9549/9973) moq-video capture::v4l2::tests::returns_an_error_when_every_probe_fails
PASS [ 0.080s] (9550/9973) moq-video capture::wgc::tests::startup_callbacks_without_usable_frames_do_not_extend_the_deadline
PASS [ 0.084s] (9551/9973) moq-video capture::wgc::tests::selectors_preserve_native_ids_and_refuse_malformed_input
PASS [ 0.931s] (9552/9973) moq-transcode tests::ended_demand_opens_no_new_live_group
PASS [ 3.216s] (9553/9973) moq-tokio::integration reconnect::two_peers_redirecting_to_each_other_escalate_the_backoff
────────────
Summary [ 52.328s] 9553/9973 tests run: 9552 passed, 1 failed, 112 skipped
FAIL [ 0.653s] (9530/9973) moq-transcode tests::live_multi_rung
stdout ───
running 1 test
test tests::live_multi_rung ... FAILED
failures:
failures:
tests::live_multi_rung
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 71 filtered out; finished in 0.64s
stderr ───
thread 'tests::live_multi_rung' (527051) panicked at rs/moq-transcode/src/lib.rs:556:44:
called `Result::unwrap()` on an `Err` value: Cancel
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: 420/9973 tests were not run due to test failure (run with --no-fail-fast to run all tests, or run with --max-fail)
error: test run failed
mbx[cache]: object cache: 798 hits, 23 misses, 84 not looked up, 73 bypassed; 0 B downloaded, 0 B uploaded, 1.1 GiB stored locally
mbx[cache]: 5m 46s session; 14m 1s estimated compiler time avoided (summed across compilations)
mbx[cache]: 84 compilations had no usable prior inputs or matching prediction for a lookup
mbx[cache]: bypass reasons: 73 unsupported-crate-type
mbx[cache]: Cargo artifact reuse and CI cache archive transfers are not included above
mbx[savings]: across 12892 builds, rustc has been excused from 10d 14h of its duties.
error: recipe `test` failed on line 319 with exit code 100
error: recipe `test-changed` failed on line 86 with exit code 100
##[endgroup]
##[error]ci: test rs failed
##[error]Process completed with exit code 100.
##[group]Run actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: cargo-timings
path: target/cargo-timings/cargo-timing-*.html
if-no-files-found: ignore
retention-days: 14
compression-level: 6
overwrite: false
include-hidden-files: false
archive: true
env:
BASE: e6be13d5f897ea98e3f2944205a2609226b18828
CHECK_FAIL_FAST: 1
NEXTEST_TEST_THREADS: 24
MBX_CACHE_LINKS: 1
MBX_REMOTE_URL:
##[endgroup]
With the provided path, there will be 1 file uploaded
Artifact name is valid!
Root directory input is valid!
Uploading artifact: cargo-timings.zip
Beginning upload of artifact content to blob storage
Uploaded bytes 87910
Finished uploading artifact content to blob storage!
SHA256 digest of uploaded artifact is e933a413cd16480f93fa0392ab72d6d048275d1ad5d3b91d7d0249a1f3e1eef1
Finalizing artifact upload
Artifact cargo-timings successfully finalized. Artifact ID 13302005272
Artifact cargo-timings has been successfully uploaded! Final size is 87910 bytes. Artifact ID is 13302005272
Artifact download URL: https://github.com/moq-dev/moq/actions/runs/41785773670/artifacts/13302005272
Post job cleanup.
##[start-action display=Run jdx/mr-boxington-action@88acf2bb50552c7c508cbac13e5f8c576b95b1de;id=__00a249f8-c456-4e51-8cac-434b0199c299.mbx]
##[end-action id=__00a249f8-c456-4e51-8cac-434b0199c299.mbx;outcome=skipped;conclusion=skipped;duration_ms=0]
Post job cleanup.
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git version
git version 2.55.0
Temporarily overriding HOME='/var/cache/github-runner-work/_temp/58d65791-7435-4348-bf40-539ca70bf6f3' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git config --global --add safe.directory /var/cache/github-runner-work/moq/moq
Removing SSH command configuration
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git config --local --name-only --get-regexp core\.sshCommand
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir:
[command]/nix/store/lg46w7hrjx7kylsh6645c9l975i8h43b-git-2.55.0/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
A job completed hook has been configured by the self-hosted runner administrator
##[group]Run '/nix/store/gx2v6q84b0w43bafm0whkdx93qyxbpps-ci-cache-gc.sh/bin/ci-cache-gc.sh'
shell: /nix/store/1mv3qz005gkbalxfghk4y3s8ayv4d2dl-bash-interactive-5.3p15/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
evicted 0 objects and 0 action results (0 B logical); 50.0 GiB logical remain
removed 0 learned incremental units and 2 checkout directories (3.7 KiB logical); 33 units (4.5 GiB logical) remain
evicted 0 objects and 0 action results (0 B logical); 50.0 GiB logical remain
removed 2 target directories (13.7 MiB logical, 2 abandoned and 0 live); 19.0 GiB logical remain
Cleaning up orphan processes
(written by quest land watch) |
|
codex / Codex land fixer note:
(written by codex / Codex) |
|
quest land watch: re-enqueued this pull request at 533ceaf, at the back of the merge queue, unchanged, since the land fixer judged the failure flaky: (written by quest land watch) |

Problem
A
group::Consumermoved 280 bytes through every layer handing a group to a reader. Completes the Consumer size quest.Approach
SESSION_ALLOCS=1benchmark. Remove the completed quest and its links.Impact
The waiter change in moq-dev/moq#7789 at ea70199e1f was inspected, not imported. Its additional 64 bytes per waiter stay behind Consumer's existing recovery/idle pointers; its boxed pending subscription variants also do not enlarge Consumer. Measurements below use main's eight-record waiter, isolating this layout change.
Performance
just bench-fanout 6647cda31b "model session" "64 512", on one pinned thread over memory transports. Median of three retired-user-instruction counts, subtracting setup, per delivered group. The measured working tree was committed as 9e0e4e05eb; later review edits leave its runtime production code unchanged:bench/fanout.py compareover setup-subtracted callgrind runs at 64 readers shows sessionmemcpyfalling from 9,347.6 to 7,217.5 instructions/group (-2,130.1); modelmemcpyfalls from 992.2 to 543.0 (-449.2).A temporary allocation counter on the exact fanout session harness, removed from the shipped change in favor of the existing benchmark, measured:
Validation
just cion final head533ceafa0964b5de151032e8f85a5cb98c750792: passed, including 9,756 Rust tests, 112 skipped.SESSION_ALLOCS=1 cargo bench --locked -p moq-net --features fuzz --bench session -- session_delivery, pinned withtaskset -c 7: passed on base and branch. All 12 group-delivery cases, spanning 16 publishers/16 viewers and 1 publisher/256 viewers, all three protocols, and paced/unpaced delivery, retain the same allocation count to the report's 0.01/group resolution. For lite-06 at 256 viewers: 96.31 allocations/group on both, 10,899 to 10,819 requested bytes/group.Alternatives
Boxing the entire Consumer would add an allocation per delivery. Copying the entire track Info into the shared allocation would retain fields these readers never use, so only the queried metadata is stored. Reused the existing session allocation counter instead of adding another maintained counter.
Review
Claude Code, Claude Opus 5.5 (
claude-opus-5-5), medium effort, round 2, reviewed head 533ceafa09. No findings.All earlier findings were fixed: reuse the existing allocation counter, clarify storage/report comments, and guard the measured layout at compile time.
Follow-ups
None. No maintainer decision remains; recommend merge review after this head is ready.
(Written by GPT-6.1 Sol)