Repository navigation
Description
Context
#2872 cut a native journal observation's own cost: one long-lived identity inspector per native manager instead of six interpreter launches per observation, and the previous checkpoint's release no longer inside the observation hold. On the native fixture (bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --observation-timing, pi, governed, UID 1000, 2,000 notes) a writer's added time fell by about 40 % and journal begin by more than half, but #2834's targets are still unmet:
write_file added (median) |
worker hold (median) | journal begin + finish (median) | |
|---|---|---|---|
| Quiet host, load 9–12, after #2872's first slice | 186 ms | 147 ms | 347 ms (begin 132, finish 234) |
| Slow storage, load 10–11, after #2872 | 358 ms | 300 ms | 801 ms (begin 212, finish 610) |
Targets: a writer under 150 ms added, begin + finish at most 300 ms.
What is known (line citations are at #2872's branch head and land with it):
- The native commands inside the hold take about 20 ms in the quiet run (snapshot 15 ms;
subvolume list,qgroup showandsend --no-data1–2 ms each), from the fixture'snative-operations.jsonl. The rest of a writer's ~140 ms hold is not attributed: candidates are the manager's two fsynced intents per checkpoint and the in-process identity inspections (async function inspection,packages/ui-sdk/src/server/native-brain-manager.ts:186-190), the client's Unix round trips, delta parsing and metadata reads inprepare(async function prepare,packages/ui-server/src/brain/native-journal-observer.ts:359), and the journal record plus facts query (async function observe,packages/ui-server/src/brain/turn-journal.ts:295-359). - Journal finish did not get faster with ui-sdk: a native journal observation's checkpoint and release keep writer calls and journal begin plus finish above #2834's targets #2872 (236–251 ms before, 234 ms after in the quiet period). It cannot be attributed from current artifacts:
native-operations.jsonlis stamped in the fixture's test process and the journal's begin/finish rows in the app process, and the app rows'wallAtdoes not separate start from end (both rows of one finish carry the same value), so the two cannot be aligned. One plausible cause, not established: finish's checkpoint queues at the manager's single operation lock behind releases the turn's earlier observations handed to the release owner (async function reserveRelease,packages/ui-server/src/brain/native-journal-observer.ts:329-335).
Scope
- Add per-phase timing for each journal observation to
--observation-timing, on one clock: reservation wait, manager checkpoint (split into qualify, snapshot, verify and intents), delta, metadata reads, journal record, facts query and commit, plus the manager lock wait for each manager operation. Record it inobservation-timing.jsonfor writer observations and for journal begin and finish. - Attribute the writer hold and journal finish from that data, and cut what can be cut without skipping any identity, immutability or qualification check, journal capture or durability step.
- Report whether ui-server: a full native journal observation runs after every tool result and delays the next request (230–860 ms per call) #2834's writer and begin + finish targets are met; if not, the remaining shortfall per phase.
Out of scope
- Which results are observed (ui-server: a full native journal observation runs after every tool result and delays the next request (230–860 ms per call) #2834's schedule).
- The release owner's ownership, bound and failure semantics (ui-sdk: a native journal observation's checkpoint and release keep writer calls and journal begin plus finish above #2834's targets #2872's ruling).
- Skipping or caching any manager check; relaxing a target.
Acceptance criteria
-
observation-timing.jsonreports per-phase medians on one clock for writer observations and for journal begin and finish, and the phases cover at least 90 % of the measured hold and finish time. - Every change that cuts a phase keeps the existing native manager and journal tests passing, and has before/after
--observation-timingruns back to back on the same host, with host load recorded. - The PR states whether the writer (< 150 ms) and begin + finish (≤ 300 ms) targets are met.
Verification
bun run test packages/ui-sdk packages/ui-server, bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --observation-timing before and after under the native fixture lock, and the full native matrix when the manager changes.
Contract impact
None expected.
Found while measuring #2872.
Evidence and dependency boundary
#2872 is open: the inspector/release-owner behavior, timings and line citations above refer to its implementation branch. Re-read its delivered version and preserve the approved release-owner bound, shutdown/accounting and stop-all-on-failure semantics before measuring this follow-up. The scheduling output from #2834 is already delivered by #2882 (1c5666e7a); #2834 itself remains the aggregate target-verification task, not a prerequisite whose closure this follow-up must await.
Compute hold and begin/finish phase durations from paired start/end stamps on one monotonic clock (or retain a proven clock mapping across processes), including queue/lock waits and unsuccessful attempts. Distinguish a median of paired begin+finish totals from the sum of independently reported medians; retain raw sample counts, missing/blocked phases, host load and before/after source identities. A documented target shortfall is valid evidence, not permission to skip checks, relax a bound or claim the aggregate target met. Keep diagnostic receipts outside authored source; any instrumentation that ships is internal and preserves provider-facing history byte for byte.
2026-10-25 triage at main 541b8d98328a760290ac6dd4a7f065af76153408: Completed the one-clock attribution/guard-preserving optimization brief, distinguished branch measurements from main and retained the actual #2872 prerequisite. The #2834 scheduling output has shipped; its aggregate completion must wait for this follow-up rather than forming a reverse dependency. Preserve existing p1 and performance/identity/durability requirements; no new timing or target success is claimed.
Activity
schlessera commentedon Oct 25, 2026
2026-10-25 triage at main
541b8d98328a760290ac6dd4a7f065af76153408: Completed the one-clock attribution/guard-preserving optimization brief, distinguished branch measurements from main and retained the actual #2872 prerequisite. The #2834 scheduling output has shipped; its aggregate completion must wait for this follow-up rather than forming a reverse dependency. Preserve existing p1 and performance/identity/durability requirements; no new timing or target success is claimed.fix(ui-sdk,ui-server): cut a native journal observation's own cost (#…
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-20a586f6. Branch:perf/2915-native-observation-phases.Path collisions: draft #3622 (turn-journal.ts), draft #3806 (native-brain-manager.ts).
DO NOT MERGE: measure base and head back to back on the hosted native…
docs(decisions): record where a native observation's time goes (#2915)
CONTRACT: perf(ui-server,ui-sdk): attribute the native observation's …
schlessera commentedon Nov 15, 2026
Delivered by #4012, squash
388feb483751e8a7550f908de6f0a518eda03117on main (milestone 0.45.0).--observation-timingnow writes per-phase medians on one clock for writer holds and journal begin and finish (phasesinobservation-timing.json, raw samples inobservation-traces.json). Coverage by median is 98–99 % of each hold, begin and finish, and at least 92.9 % of every sample. Every checkpoint and delta step paired with exactly one manager request: start slack ≥ 0.2 ms, end slack ≥ 0.6 ms.3f8ff293, writers add 67–76 ms and begin + finish takes 62 ms. With the instrumentation, writers add 68–72 ms and begin + finish takes 68 ms. The trace costs nothing measurable.docs/decisions/governed-writable-workers.md, "Where an observation's time goes". ui-server: a full native journal observation runs after every tool result and delays the next request (230–860 ms per call) #2834 remains the aggregate verification.