input-capture: README states the real per-event lock counts

QA finding 3: the Assumptions bullet claimed "three acquisitions per
event at most (snapshot, virtual cursor, counters)", which named neither
`Screens` nor `CaptureQueue` and undercounted every path. Replaced with
the four lock objects the callback can reach and the count on each of the
four paths — local key 2, local move 3-4, remote key 3, remote move 5-6 —
counted from the code, with the extras (unmapped key, hotkey, escape,
modifier transitions) spelled out.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 02:34:28 -07:00
1 parent ece6bbf8fd
commit 09df9c09b2
1 file changed
+19 -2
+19 -2
View File
@@ -36,8 +36,25 @@ code does not enforce is here.
the destination is remote, convert to `CapturedInput`, push and swallow
(`InputHook.cs:361-368` keyboard, `:322-325` mouse); if local, push mouse
*moves only* so `Edge` can watch for a crossing, and pass everything through.
Three uncontended `OSAllocatedUnfairLock` acquisitions per event at most
(snapshot, virtual cursor, counters) and no allocation (invariant 4).
No allocation on any of it (invariant 4).
- **Four locks are reachable from the callback**, all uncontended
`OSAllocatedUnfairLock`s held only for a struct copy: `EventTap.counters`,
`RoutingState`'s box (the snapshot *and* the virtual cursor share it),
`Screens`' layout and `CaptureQueue`'s ring. Counted from the code, per
event, on the four paths that matter:
- **local key**: 2 — `counters`, snapshot read. An unmapped key adds one
`counters`; a matched hotkey adds one ring push, and an escape hotkey one
more `RoutingState` write.
- **local mouse move**: 3 — `counters`, snapshot read, virtual-cursor write;
4 when Easy Mouse lets the move be offered as an `.edgeCandidate` (one ring
push). `Screens` is not read on this path.
- **remote key**: 3 — `counters`, snapshot read, one ring push. A
`flagsChanged` pushes once per modifier transition instead, and twice more
for a Caps Lock toggle.
- **remote mouse move**: 6 — `counters`, snapshot read, virtual-cursor
advance, `Screens`' layout, then two ring pushes (`.mouse` and
`.edgeCandidate`); 5 when the candidate is suppressed. This is the worst
path in the file.
- **Swallowing is a separate flag from the destination.** ALL-machines mode
sends input to every peer *and* keeps it locally (`InputHook.cs:361`), so
`swallowKeys`/`swallowMouse` are set by the Engine, not derived here.