Skip to content

perf(obs-callback): one lock fewer and no generation bump per global signal pass (#3350) - #3427

Merged
zackees merged 1 commit into
masterfrom
perf/3350-signal-percb
Nov 1, 2026
Merged

zackees merged 1 commit into
masterfrom
perf/3350-signal-percb

Conversation

@zackees

@zackees zackees commented Nov 1, 2026

Copy link
Copy Markdown
Member

Refs #3350 (under #3176). This is the global-callback half of #3410.

Change in Signals::signal's global pass, as #3410 did for the per-signal pass:

  • signalling rises under the first snapshot chunk's lock, not in a separate lock: one lock fewer per emit.
  • The end-of-pass sweep bumps generation only if it removed an entry. A plain pass no longer invalidates snapshots in other passes.

Behaviour is unchanged: all 87 callback:: tests pass, including the reentrancy, connect/disconnect-in-callback and global-callback cases and the C-oracle parity. ./lint passes. There are no new tests (a pure perf change to covered code, as in #3410).

Measured. port_comparison signal/emit_global/4, interleaved master/change runs on a busy host (load average about 12), criterion 4 s:

run master rust change rust c
1 248.6 ns 225.8 ns 87–107 ns
2 241.5 ns 221.5 ns 88 ns

That's about −9%. The remaining gap to C is per-callback (the snapshot copy, the thread-local index store and the closure call), and #3350 stays open for it.

@zackees
zackees enabled auto-merge November 1, 2026 12:30
@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into master with commit 663d8f7 Nov 1, 2026
41 checks passed
@zackees
zackees deleted the perf/3350-signal-percb branch November 1, 2026 12:46
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