Add a per-client frame budget tripwire to the render host - #24
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Greptile SummaryAdds per-client render-frame timing and budget diagnostics to the macOS shared-renderer host.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| 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
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.
|
@greptileai review |
1 similar comment
|
@greptileai review |
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).
NATIVE_SDK_GPU_FRAME_TRACE=1emits a per-frame line for future receipts.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.Tests: test-canvas 841/841; new
test-macos-render-host-frame-budgetcontains-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.