`scripts/window-drag-probe/` (AppleScript + harness + README) and AGENTS.md.
## Control
Idle baseline, same guest, Safari open, no motion, 15 s:
drain_duty tranches=249 busy_us=613 duty=0.001 max_tranche_us=8
draws=0 flushes=0 slow_tranches=0/249
Zero draws, zero flushes, worst tranche 8 us. So the duty=0.98, ~130 ms tranches
and 641 ms/s of flush measured under motion are entirely caused by the motion and
none of it is a standing cost. Reproduced the motion run too: present_hz med
10.65 against 10.90, duty 0.98 against 0.97, max_tranche med 135112 against
128831 — stable, not a one-off.
## The defect the control found
The first attempt at the control asked for "15 s at 12 Hz" and the reposition
motion took --hz as a step *count*: 180 moves flat out, finished in 1.9 s, and
the counters were reported as though they covered fifteen seconds. A third of
the intended window, presented as the whole one.
The AppleScript loop is now duration-based, and --hz is documented as applying to
--motion drag only, with the status line saying so at run time. System Events
sets the rate here (~115 Hz) and the run reports what it achieved. A knob that
appears to be honoured and is not is worse than one that is absent — and this
one would have silently shortened every future control taken with it.
## AGENTS.md
Records the goal 6 numbers, the idle control that licenses reading them as the
motion's cost, and the two cautions: the stressor is an accessibility reposition
rather than a pointer drag (with the measured reason a real drag is unavailable
on this guest), and nothing in the numbers separates guest-requested work from
device-added work. 48 flushes per presented frame is named as the next question.
## Verified
Both runs live on a settled x86/PCI guest, output quoted verbatim in the README.
`bash -n` clean. No Rust touched.
51 lines
2.3 KiB
AppleScript
51 lines
2.3 KiB
AppleScript
-- reposition.applescript — move a window along a path as fast as the
|
|
-- accessibility API allows, for a fixed number of steps.
|
|
--
|
|
-- This is the fallback motion, and it is not a pointer drag. A real drag needs
|
|
-- CGEventPost (see drag.c), whose events this guest silently discards because
|
|
-- the posting process is not trusted for Accessibility and TCC.db cannot be
|
|
-- written here: there is no passwordless sudo and SIP's Filesystem Protections
|
|
-- are on. System Events *is* trusted, so this route moves the window while the
|
|
-- other one does not.
|
|
--
|
|
-- What that costs is stated rather than glossed: the window server sees a
|
|
-- sequence of window moves instead of a pointer held across a title bar, so any
|
|
-- work specific to a drag session is missing. What it keeps is the part the
|
|
-- device sees — a large window changing position at high rate, and everything
|
|
-- behind it recomposited.
|
|
--
|
|
-- Runs for a duration rather than a step count, and cannot be paced: each
|
|
-- `set position` is a synchronous round trip through System Events, so the rate
|
|
-- is whatever that costs (~100 Hz measured) and `--hz` has no meaning in this
|
|
-- mode. Taking a step count instead was a real defect — asking for 15 s at 12 Hz
|
|
-- ran 180 steps flat out and finished in 1.9 s, so the run measured a third of
|
|
-- the intended window and reported it as if it were the whole one.
|
|
--
|
|
-- Returns the number of steps performed; the caller times the run, because
|
|
-- AppleScript's `current date` has one-second resolution and cannot.
|
|
on run argv
|
|
set appName to item 1 of argv
|
|
set x0 to (item 2 of argv) as integer
|
|
set y0 to (item 3 of argv) as integer
|
|
set secs to (item 4 of argv) as integer
|
|
set ampX to (item 5 of argv) as integer
|
|
set ampY to (item 6 of argv) as integer
|
|
|
|
set done to 0
|
|
set t0 to current date
|
|
tell application "System Events" to tell process appName
|
|
repeat with i from 1 to 1000000
|
|
if ((current date) - t0) ≥ secs then exit repeat
|
|
-- Two incommensurate periods, so the path is not a straight slide,
|
|
-- which is the one motion a compositor may coalesce. Integer
|
|
-- arithmetic only: AppleScript has no cheap sine and the point is
|
|
-- the motion, not its exact shape.
|
|
set dx to ((i * 7) mod (2 * ampX)) - ampX
|
|
set dy to ((i * 11) mod (2 * ampY)) - ampY
|
|
set position of window 1 to {x0 + dx, y0 + dy}
|
|
set done to done + 1
|
|
end repeat
|
|
end tell
|
|
return done
|
|
end run
|