Skip to content

perf(obs-callback): one lock and one thread-local fewer per signal pass (#3350) - #3410

Merged
zackees merged 1 commit into
masterfrom
perf/3350-emit-gap
Nov 1, 2026
Merged

zackees merged 1 commit into
masterfrom
perf/3350-emit-gap

Conversation

@zackees

@zackees zackees commented Nov 1, 2026

Copy link
Copy Markdown
Member

Refs #3350 (the rest of the gap stays open).

Three cuts to the per-emit work in SignalHandler::signal's signal pass. None changes behaviour:

  • signalling += 1 moves under the first snapshot chunk's lock, so each emit takes the callbacks mutex three times instead of four.
  • The signal pass leaves CURRENT_GLOBAL alone. It now swaps CURRENT_SIGNAL only. remove_current reads CURRENT_SIGNAL first, so while a signal callback runs, the global slot is never consulted. Its value is restored on exit, unchanged.
  • The end-of-pass bump happens only when the sweep removed entries. With signalling == 0 no pass on this signal is running, so nothing reads the generation unless the list changed. The sweep moves into end_signal_pass to keep signal() under clippy's line limit.

Measured. port_comparison (rust/obs-c-oracle/benches), criterion 5 s, load avg about 4–5:

master this PR
signal/emit/4/rust 174.3 ns 157.0 / 152.4 ns (two runs)
signal/emit/4/c 83.7 ns 79.9 / 79.2 ns
ratio 2.08× 1.92–1.97×

RED/GREEN. This is a perf change, so the RED is the measurement above. The correctness guard is the existing callback:: suite in obs-tests-core: 87 tests, including signal_parity against the C oracle (Tier 3). It passes before and after; there is no new failing test to show. ./lint passes.

Test cost: no new tests.

Not user-visible; no features.md line.

@zackees
zackees enabled auto-merge November 1, 2026 10:52
@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into master with commit 59833c2 Nov 1, 2026
41 checks passed
@zackees
zackees deleted the perf/3350-emit-gap branch November 1, 2026 11:09
zackees added a commit that referenced this pull request Nov 5, 2026
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.
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Nov 7, 2026
* test: record signal emission performance RED (obs-rust#3350)

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 obs-rust#3410/obs-rust#3427; behavior remains covered by existing callback suite.

* perf: remove redundant signal pass locking (obs-rust#3350)

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.

* fix: split global signal dispatch to satisfy lint (obs-rust#3350)

* perf: skip unchanged signal callback list locks (obs-rust#3350)
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.

1 participant