Skip to content

perf: bring signal emission within C comparison target - #3657

Merged
zackees merged 4 commits into
masterfrom
fix/3350-signal-acceptance
Nov 7, 2026
Merged

zackees merged 4 commits into
masterfrom
fix/3350-signal-acceptance

Conversation

@zackees

@zackees zackees commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #3350.

Signal emission with connected callbacks exceeded the 1.5× C performance target. The outer reentrant guard now holds its standard mutex across callbacks; recursive entry uses its thread owner token. Atomic list-emptiness flags remove the preliminary callback-list lock. Pass depth remains protected by the reentrant lock, and an unchanged outer-pass generation skips the final callback-list lock and sweep. Mutating callbacks still refresh snapshots and sweep marked entries at the outermost return, preserving callback order, recursive connect/disconnect, and disconnect exclusion.

RED: e816030cc records the performance failure on master 75a8dd7f1. GREEN: 0502c2a3b, 0e479bf0a, and 795f9ce71.

Criterion mean Before Rust / C After Rust / C After ratio
signal/emit/4 138.56 / 86.23 ns (1.607×) 96.642 / 87.360 ns 1.106×
signal/emit_global/4 215.51 / 84.91 ns (2.538×) 146.159 / 99.603 ns 1.467×

Final measurement: SOLDR_RUSTC_WRAPPER=none soldr cargo bench -p obs-c-oracle --bench port_comparison -- 'signal/(emit/4|emit_global/4)' --sample-size 100 --measurement-time 5 --warm-up-time 2, run sequentially after local tests/lint stopped. Both mean ratios meet 1.5×. The global result is close to the limit; these are one host run, not a guarantee across machines. Final mean 95% confidence intervals: emit Rust 95.70–97.61 ns / C 86.37–88.43 ns; global Rust 144.52–147.91 ns / C 97.52–101.80 ns. Before/after host load differs, so ratios to each run's C control are the acceptance comparison.

Validation:

  • soldr cargo test -p obs-data --test obs-tests-core callback::: 90 passed, 0 failed, 0.15 s on final implementation, including exact C-oracle parity, nested mutations, chunk boundaries, self-removal and concurrent disconnect/waiter cases.
  • Focused callback Clippy with -D warnings, workspace rustfmt check, all 11 structural performance guards, and all 15 guard tests pass.
  • Read-only pre-push review is clean, including atomic publication, recursive depth/generation, unwind lock ownership, and closure destructor order.
  • Full local ./lint is incomplete: stopped only this run's process tree after several minutes in unrelated ci/test_platform_missing_prototypes.py on a heavily loaded shared host. Required PR Fast Gate remains the full lint gate. No local attestation claimed.
  • Tier 2 unchanged C compatibility is covered by the selected required PR CI; no public headers or existing C tests changed. Tier 4 does not apply to internal callback dispatch.

Test cost: no new tests, test executables or threads.

Local evidence: soldr logs 20261105T065217Z (final callback tests), 20261105T065014Z (Clippy), 20261105T065317Z (fmt), and 20261105T065828Z (final benchmark). Interrupted full-lint capture: local-test-OkvwZZ.log.

Cleanup landing decision

The maintainer authorized resolving prior draft holds. Earlier comments describe intermediate measurements; the final body measurements at 795f9ce71b8727976808cc7ea00cb91f0efa2b66 meet both issue bounds (1.106× and 1.467×). The global result remains close to the limit and host-dependent as disclosed above. Final required PR Fast Gate and all selected unchanged C Tier 2 ON/OFF and serial jobs passed. Reviewed the complete diff; no competing open signal-acceptance PR or later conflicting claim was found. No new test or weakened acceptance bound is introduced by this cleanup. The branch is conflict-free with master; repository coordination policy §4 delegates unrelated base updates to the merge queue. Queue admission will be pinned to the validated head.

@zackees

zackees commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Checkpoint at 82aa4bbe8:

  • Existing callback suite: 90 passed before and after (OBS_PARITY_CASES=reduced soldr cargo test -p obs-data --test obs-tests-core callback::). This includes C-oracle random scripts, nested/self/other disconnect, multi-chunk mutation, disconnect exclusion, and multiple waiters.
  • Pre-push local review: clean. Performance structural guard: all11guards hold; focused guard-linter tests pass. Formatting passed through soldr cargo fmt --all and git diff --check.
  • First post-change criterion means: emit4 Rust156.64ns/C146.76ns (1.067x); global4 Rust277.62ns/C273.62ns (1.015x). However confidence intervals were very wide and the C baseline moved sharply while the16CPU host load reached83.
  • A longer100sample repeat launched with CPU affinity gave emit4 Rust528.93ns/C235.20ns (2.249x), global4 Rust222.68ns/C129.98ns (1.713x). The daemon warned that it retained its previous concurrency configuration. These results do not establish the1.5x acceptance target; do not close perf: obs-callback: signal emit with callbacks connected is ~3.7x C #3350 from this run.

The draft preserves a focused, reviewed optimization with passing behavior tests. Full local lint is still running. PR CI41980826576 has no failures so far; Fast Gate and Linux Tier2 build remain active. Keep the PR draft until validation and repeatable measurements justify the next step.

Local evidence artifacts: baseline /home/niteris/.soldr/logs/porcelain/20261105T062220Z-home-niteris-dev-obs-rust-obs-studio.log; GREEN callback suite 20261105T062628Z-home-niteris-dev-obs-rust-obs-studio.log; first GREEN bench 20261105T062646Z-home-niteris-dev-obs-rust-obs-studio.log; longer repeat 20261105T063123Z-home-niteris-dev-obs-rust-obs-studio.log in the same directory.

Current master 75a8dd7: signal/emit/4 Rust mean138.56ns vs C86.23ns (1.607x), signal/emit_global/4 Rust215.51ns vs C84.91ns (2.538x); both exceed acceptance1.5x. Command: soldr cargo bench -p obs-c-oracle --bench port_comparison -- signal/emit(_global)?/4 --sample-size50 --measurement-time2 --warm-up-time1. Evidence: /home/niteris/.soldr/logs/porcelain/20261105T062220Z-home-niteris-dev-obs-rust-obs-studio.log. Performance RED is measurement, following #3410/#3427; behavior remains covered by existing callback suite.
Hold the outer mutex guard through each pass and use an owner token for same-thread recursive acquisition. Skip terminal empty snapshots when callbacks did not change the generation. Preserve callback exclusion, nested remove-current behavior, and waiter notification through the standard mutex.
@zackees
zackees force-pushed the fix/3350-signal-acceptance branch from 82aa4bb to 0e479bf Compare November 5, 2026 06:42
@zackees

zackees commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Pushed lint repair 0e479bf0a: extracted global dispatch into a borrowed-closure helper, preserving closure destructor order and callback semantics. The original Fast Gate failure was Clippy too_many_lines (114/100), not the expected GATE-SOURCE-PROBE diagnostics. Focused Clippy and callback tests now pass; read-only review is clean.

Performance acceptance remains incomplete. New Criterion run (50 samples, 5s measurement, 2s warmup) measured emit/4 means Rust 160.141 ns vs C 120.665 ns (1.327x), and emit_global/4 Rust 171.677 ns vs C 95.286 ns (1.802x). The global path still exceeds 1.5x; this PR remains draft and #3350 remains open. Prior baseline and noisy repeats are documented above. Local evidence: soldr logs 20261105T064003Z (benchmark), 20261105T064025Z (callback tests), 20261105T064113Z (Clippy).

@zackees zackees changed the title perf: remove redundant signal pass locking perf: bring signal emission within C comparison target Nov 5, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In progress in obs-rust Multiview Nov 5, 2026
@zackees
zackees marked this pull request as ready for review November 7, 2026 03:33
@zackees
zackees added this pull request to the merge queue Nov 7, 2026
Merged via the queue into master with commit 1b7c033 Nov 7, 2026
42 of 44 checks passed
@zackees
zackees deleted the fix/3350-signal-acceptance branch November 7, 2026 03:43
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to Done in obs-rust Multiview Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

perf: obs-callback: signal emit with callbacks connected is ~3.7x C

1 participant