# gpui: Journal foreground work between frames and report hang incidents \(\#62779\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1861e58f984c76afc06032e753557994ffc8fe44)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1861e58f984c76afc06032e753557994ffc8fe44

Requested commit: 1861e58f984c76afc06032e753557994ffc8fe44

Commit: 1861e58f984c76afc06032e753557994ffc8fe44

Tree: e7f6d3e52a1a708d5a983e868b5eb1614011696e

Author: Anthony Eid

Committer: GitHub

## Message

```
gpui: Journal foreground work between frames and report hang incidents (#62779)

Zed's hang telemetry could say a hang happened, but not what the app was
doing. This PR adds a foreground journal to gpui (behind the `profiler`
feature): the main thread records task polls, action handlers, input
dispatches, window draws, and frame presentations into a fixed-size
ring, and boundary entries — a newly drawn frame's presentation, or the
foreground going idle — partition that stream into activity intervals.
Recording is designed to be cheap enough to ship enabled: sub-threshold
task polls fold into a counter instead of individual entries, and the
ring is drained in bounded chunks off the main thread.

A `HangDetector` drains the journal and reports an incident for any
interval containing a single event at or above the hang threshold (100ms
in release), or whose cumulative foreground spend reaches a frame budget
(8ms in release) — catching both one long stall and many small pieces of
work that together drop a frame. Incidents serialize with phase
(startup/steady), stall and active durations, busy fraction,
dirty-to-present time, and up to 8 contributors in start order with
nesting depth: task polls carry their spawn location, actions their
names, inputs their kind. Zed batches the top 10 incidents by stall per
30 minutes plus a total incident count into a "Hang Incidents" telemetry
event, flushes the remainder on quit, and drops the old per-location
"Hang Report" histograms this replaces.

Release Notes:

- N/A
```

## Parents

- [2936989f1b7a15aaf7131b0a3c17961d706fdbf5](https://git.cafe/gitcafe/zed/commit/2936989f1b7a15aaf7131b0a3c17961d706fdbf5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1861e58f984c76afc06032e753557994ffc8fe44?format=markdown)
