docs: record the measured idle-cost A/B behind the sampling changes
The section quoted the sidecar's own micro-benchmark, which is not a number anyone can reproduce. Replaced with a per-process A/B against the installed 0.1.11 over 60 s idle: the sidecar drops 140 ms to 40 ms, and that row is the only one that can be attributed cleanly, because the sidecar has no window and so cannot be confounded by whether the main window is open. The main-process row is explicitly not offered as "the discovery thread saved 40%": repeated runs of the same build swing by about 40 ms, the same order as the difference itself. Saying so is cheaper than letting the next person quote a coin flip. Co-Authored-By: Codex <noreply@openai.com>main
parent
9ba619c352
commit
a95aebe1d0
|
|
@ -497,9 +497,25 @@ cd src-tauri && cargo test --lib editor
|
|||
Shift 绝大部分时间是停在菜单栏里没人碰的。这一节的每条节奏都是从实测里挑出来的,
|
||||
目的是把"关掉了就别一直占 CPU"和"还听得见、还能过期"同时满足。
|
||||
|
||||
### 实测的 A/B
|
||||
|
||||
在装有 0.1.11 的机器上,两个版本各自空转 60 秒,按进程分别读 `ps -o time=`:
|
||||
|
||||
| 进程(60 秒空转) | 0.1.11 | 0.1.12 | 变化 |
|
||||
| --- | --- | --- | --- |
|
||||
| `drag-bridge` 伴生进程 | 140 ms | 40 ms | **−71%** |
|
||||
| `shift` 主进程 | 100 ms | 60 ms | −40% |
|
||||
| 合计 | 240 ms | 100 ms | **−58%** |
|
||||
|
||||
只有伴生进程那一行可以直接归因:它没有窗口,所以不受"主窗口有没有开着"影响,
|
||||
而其余三处改动都发生在那两个数字里。主进程那一行不能当成"发现线程省了 40%"来读——
|
||||
同一个构建重复测量的摆动就有 ±40ms,和差值同量级。发布前若要再引用一次,
|
||||
请重新测,不要抄这张表。
|
||||
|
||||
|
||||
| 位置 | 节奏 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| `native/macos/drag-bridge.swift` | 无按压 10Hz,按住切 30Hz | 伴生进程是**另一个被跟踪的进程**,原先永远 30Hz,而且每跳都分配一个 CGEvent 去读一个没人要的鼠标位置。与 0.1.11 的产物 A/B:空转 6 秒 20ms CPU → 0ms,按住 12 秒两边都是 30ms——手势采样一点没变粗。`NSTimer` 不能改自己的间隔,所以是换掉计时器而不是调它。 |
|
||||
| `native/macos/drag-bridge.swift` | 无按压 10Hz,按住切 30Hz | 伴生进程是**另一个被跟踪的进程**,原先永远 30Hz,而且每跳都分配一个 CGEvent 去读一个没人要的鼠标位置。它是这一节里唯一能被干净归因的改动:伴生进程没有窗口,所以它的 CPU 与「主窗口是否开着」无关。`NSTimer` 不能改自己的间隔,所以是换掉计时器而不是调它。 |
|
||||
| `src-tauri/src/drag_bridge.rs` `monitor_pause`(Windows) | 圆环开着 33ms,关了 250ms | 圆环开着时必须 33ms:这条循环要靠观察到"按下"才能从按下点量起拖拽阈值,放慢不是"晚一点发现",而是**根本记不住按下**,于是快速拖动的用户从此开不了环。只有关掉圆环时才敢放慢,那时要等的只有开关本身。 |
|
||||
| `src-tauri/src/share.rs` 发现线程 | 信标 2s / 扫段 30s 不动;静默时收包等待 400ms→1.6s,无 peer 时账目检查 600ms→2.4s | **关掉 ShiftDrop 不等于变聋**:字段注释写的是"不主动播报",`recv_from` 从来不受 `enabled` 约束,所以一台关掉的机器仍然听得见、仍然能被别人选来发送;`expire()` 也必须继续跑,否则一小时前的 peer 会永远挂在列表里冒充在线。所以省的是唤醒次数,不是探测能力。播报与扫段的频率一点没动,peer 被发现的速度因此不变。 |
|
||||
| `src/components/MainWindow.tsx` 30 秒时钟 | 页面可见才跑 | 主窗口一生大部分时间是隐藏的;隐藏的页面里每 30 秒重绘一次没人看的列表,正是 nex_squid `useSystemSnapshot` 用 `visibilitychange` 停掉的那类开销。空列表连 `setNowTick` 都省了——重新计时的是不存在的行。 |
|
||||
|
|
|
|||
Loading…
Reference in New Issue