Skip to content

ui-server: attribute and cut the native observation's remaining writer hold and journal finish after #2872 #2915

Closed

Description

@schlessera

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 show and send --no-data 1–2 ms each), from the fixture's native-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 in prepare (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.jsonl is stamped in the fixture's test process and the journal's begin/finish rows in the app process, and the app rows' wallAt does 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 in observation-timing.json for 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

Acceptance criteria

  • observation-timing.json reports 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-timing runs 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

  1. added
    type: fix
    area: ui-sdk
    area: ui-server
    priority: p1
    agent-ready
    blocked
    on Oct 25, 2026
  2. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    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.

  3. removed
    blocked
    on Oct 25, 2026
  4. added this to the 0.45.0 milestone on Oct 25, 2026
  5. self-assigned this
    on Nov 15, 2026
  6. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    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).

  7. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Delivered by #4012, squash 388feb483751e8a7550f908de6f0a518eda03117 on main (milestone 0.45.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-sdkarea: ui-serverpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions