Skip to content

Add a per-client frame budget tripwire to the render host - #24

Merged
SunkenInTime merged 2 commits into
weaver-mainfrom
agent/macos-render-host-budgets
Jul 31, 2026
Merged

Add a per-client frame budget tripwire to the render host#24
SunkenInTime merged 2 commits into
weaver-mainfrom
agent/macos-render-host-budgets

Conversation

@SunkenInTime

Copy link
Copy Markdown
Owner

Slice 4 (native half) of the macOS shared-renderer plan — the per-client frame budget the handoff doc requires for the cutover: one host serving N widgets is a new tripwire surface, and the budget must name itself when it fires (weaver CLAUDE.md discipline).

  • Every frame's host-side render time is measured, arrival to GPU-completed reply, on all paths (export, static fast path, refusal). NATIVE_SDK_GPU_FRAME_TRACE=1 emits a per-frame line for future receipts.
  • A frame over budget logs: FRAME BUDGET EXCEEDED pid=<client> took=<N>ms budget=250ms trips=<K> — this widget is starving its neighbors; look at its packet size/content. Budget, limit, ask, offender — an agent can act from the message alone.
  • The number has a receipt (measured live on the M3 Pro through this host, review-candidate binary): myclock median 1.4 ms/frame, worst 21.9 ms (warmup first present), n=20. The 250 ms tripwire is >11x the worst observed frame — no good widget ever feels it.
  • Enforcement is deliberately measurement-first: the trip logs and counts, no throttle until a real starvation case earns one (recorded as the next tripwire decision, not smuggled in here).

Tests: test-canvas 841/841; new test-macos-render-host-frame-budget contains-check pins the tripwire's invariants; the weaver half of slice 4 (weaverd owns the host lifecycle, shared renderer becomes the macOS default) follows in the weaver repo.

One host serving N widgets means a pathological widget can starve its
neighbors — and a starved neighbor looks like the host's bug. Every
frame's render time is now measured (host-side frame-trace line under
NATIVE_SDK_GPU_FRAME_TRACE for future receipts), and a frame exceeding
the budget logs a line naming the budget, the measured cost, the
client pid, and the trip count — enough for an agent to act on without
reading this code.

The budget is a tripwire, not a cap widgets feel: 250 ms against a
measured live receipt of median 1.4 ms per myclock frame (worst
21.9 ms, the warmup first present; n=20, M3 Pro) — >11x the worst
observed. Enforcement stays measurement-first: no throttle until a
real starvation case earns one.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7755d026-2c2b-4455-8eae-f7c0f69dcc58

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

Adds per-client render-frame timing and budget diagnostics to the macOS shared-renderer host.

  • Records completed-frame durations with a suspend-excluding monotonic clock.
  • Logs opt-in per-frame traces and over-budget trip counts.
  • Adds a build-time contents check for the frame-budget instrumentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/platform/macos/appkit_host.m Adds monotonic frame-duration tracking, trace output, and per-client budget-trip accounting across render completion paths.
build.zig Adds a source-contents test that pins the frame-budget constant and diagnostic markers.

Reviews (2): Last reviewed commit: "Time frames monotonically and from arriv..." | Re-trigger Greptile

Comment thread src/platform/macos/appkit_host.m Outdated
Comment thread src/platform/macos/appkit_host.m Outdated
Frame durations now use clock_gettime_nsec_np(CLOCK_UPTIME_RAW): the
file's NSDate timestamps serve event ordering, but a wall-clock step
mid-frame would corrupt the unsigned elapsed subtraction into a false
or suppressed budget trip. The clock also starts at frame ARRIVAL
(after the overlap guard, which must not clobber the in-flight frame's
stamp) so validation, first-frame renderer construction, and refusals
count as the host work they are.
@SunkenInTime

Copy link
Copy Markdown
Owner Author

@greptileai review

1 similar comment
@SunkenInTime

Copy link
Copy Markdown
Owner Author

@greptileai review

@SunkenInTime
SunkenInTime merged commit ad0af8b into weaver-main Jul 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant