Skip to content

Scheduling latency: measurement tooling and hotkey-path foreground cache - #1

Merged
NotBadSlime merged 5 commits into
mainfrom
perf/scheduling-phase1-2
Oct 14, 2026
Merged

NotBadSlime merged 5 commits into
mainfrom
perf/scheduling-phase1-2

Conversation

@NotBadSlime

Copy link
Copy Markdown
Owner

Summary

  • Benchmark now reports P99.9, max and over-threshold rates.
  • Opt-in hook self-time recorder (MACROHID_HOOK_SELFTIME=1), allocation-free.
  • Opt-in per-batch native trace (MACROHID_BATCH_TRACE=1, MhpGetBatchTrace); MhpRunOptions layout unchanged. Managed interop/CSV export is not wired yet.
  • Foreground process name is cached per (hwnd, pid) and re-validated on every call: the lookup cost drops from p50 26us / p99 48us to ~0.1us when the foreground is unchanged.
  • Plan and results: docs/superpowers/plans/2026-10-14-scheduling-latency-phases.md.

Deliberately not shipped (measured, see plan doc)

  • Moving TriggerPressedAsync off the hook thread: handoff costs p50 25us / p99 74us vs 27us / 131us saved, so it trades hook dwell for macro start latency with no net gain.
  • Targeted scheduler wake-ups: passed native regression but balanced-mode P99.9 was worse in 3/3 paired rounds (~485 vs ~390us). Reverted.
  • Spin-window decay: not validated; machine noise too high to resolve it.

Test plan

  • Managed suite: 390 passed
  • Native regression passes, including enabled/disabled batch trace
  • EndToEndProbe and native DLL build
  • Not verified: physical hotkey run with MACROHID_HOOK_SELFTIME=1 on the real app; the single-macro A/B was too noisy on this machine to show "no regression" for the disabled trace path

🤖 Generated with Claude Code

NotBadSlime and others added 5 commits October 14, 2026 17:01
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Enable with MACROHID_HOOK_SELFTIME=1; summary is logged on hook disposal.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…BatchTrace export

Records batch index, nominal/effective due, submit begin/end, sent count, cpu,
worker and error. Disabled by default; MhpRunOptions layout is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The hotkey path no longer calls Process.GetProcessById on every press
(p50 26us, p99 48us measured) while the foreground is unchanged. Each call
still re-reads the foreground pair, so results are never stale.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@NotBadSlime
NotBadSlime merged commit fa2629e into main Oct 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant