# gpui: Settle benchmark app state between task iterations \(\#62587\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0307288d903afd5673c361c548bd448fc8a684df

Requested commit: 0307288d903afd5673c361c548bd448fc8a684df

Commit: 0307288d903afd5673c361c548bd448fc8a684df

Tree: a6562a4b0251f893b0450b05116aa5a4f83fb00a

Author: Anthony Eid

Committer: GitHub

## Message

```
gpui: Settle benchmark app state between task iterations (#62587)

Dropped entities are released only inside an update's effect flush, and
releases cascade: one flush drops the entities whose handles are gone,
their drops release further handles and can queue foreground work, and a
later flush collects those. `BenchAppContext` callers that only pump the
executor between iterations therefore saw torn-down state linger in the
entity map until some woken task happened to run an update — in a
downstream benchmark this looked like a per-iteration leak of the whole
app graph (~35 MB per iteration), releasing on an apparently timer-bound
schedule.

This adds `BenchAppContext::settle`, which alternates draining queued
work with GPUI update cycles until the dispatcher reports idle,
mirroring the update cadence production gets for free from frames and
input events. `bench_batched_task` now settles before each iteration's
setup (outside the timed interval), so the previous iteration's state is
fully released and cannot accumulate across a measurement. A new
`ThreadedDispatcher::is_idle` predicate backs the loop's termination and
is covered by a unit test.

Release Notes:

- N/A
```

## Parents

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

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