mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-24 01:20:29 +01:00
f0fb48c71a
## Summary Keep foreground-work measurements and per-window presentation expectations valid across observed sleep/wake and visibility changes. Simplified after review to about 530 changed lines including tests and configuration. ## Scope - Keep all measurement state in the foreground-local journal writer. Use `PowerState` and `PowerTransition`; no new locks, counters, or changes to the ring protocol. - Work that started at or before the last power transition (or while suspended) is dropped when it completes: task polls before small-poll folding, and actions, inputs, draws, and presents through the same `power_interrupted_since(start)` check. No per-activity state is added; every measurement already carries its start time. - Track visibility and pending frames together per window. Hiding or sleeping clears the presentation expectation; on recovery `Window::refresh_visibility` re-records it from the window's actual dirty state, so the journal never guesses. Old latency associations remain invalid. - Repeated notifications for the same power state are ignored, so a duplicate wake does not invalidate in-flight work. - The journal subscribes to GPUI's existing power notifications and rechecks native window visibility after wake. App only registers these subscriptions (two initialization lines). - Keep the existing one-second pending-frame deadline and foreground-turn sealing behavior. No watchdog, recurring timer, test-app exceptions, unfinished-hang detection, start/end ring notices, or reader-side deduplication. - Remove lifecycle counters. Keep measurement version 2 on reports and a valid dirty-to-present sample count for weighting averages. ## Telemetry - `Hang Incidents` gains `report_window_seconds` and stall percentiles over every incident in the window (`stall_p50_ms`, `stall_p95_ms`, `stall_max_ms`, from an `hdrhistogram`), so stall distributions no longer depend on the censored `incidents[]` list. Reports are now sent even when no incident occurred, so summing `report_window_seconds` gives observed running time for incident rates. - `Frame Duration Report` gains dirty-to-present percentiles (`dirty_to_present_p50_ms`, `dirty_to_present_p95_ms`, `dirty_to_present_max_ms`) alongside the existing average, and `average_present_interval_ms` (mean frame-to-frame interval while animating, a proxy for the display's refresh interval when normalizing dirty-to-present). Detection remains completion-based. This does not solve hangs that never return or force an interval to seal when no further foreground events arrive. Existing legacy hang logs/trace triggers are unchanged. Late or coalesced platform notifications remain a coverage limitation. ## Validation - `corgi test -p gpui --features profiler --lib`: **392 tests passed**. - Focused lifecycle/wake tests also passed a 20-seed run. - The extension-suggestion regression that failed on all three CI platforms now passes locally after removal of the watchdog/test-construction changes. - `corgi check -p gpui` and `corgi check -p zed -p input_latency_ui` passed. - Formatting and `git diff --check` passed. - Corgi configuration includes only the three existing GPUI image/font fixtures needed to run its tests. Native platform sleep/wake testing and review remain outstanding. The README review marker remains for the human author to remove manually after review. Release Notes: - Improved the accuracy of hang and frame-latency telemetry around sleep, wake, and hidden windows. - [GPUI] Added a `PowerTransition` interval boundary and `measurement_version` to profiler hang reports.