Skip to content

gpui: Settle benchmark app state between task iterations - #62587

Merged
Anthony-Eid merged 2 commits into
mainfrom
bench-context-settle
Aug 13, 2026
Merged

gpui: Settle benchmark app state between task iterations#62587
Anthony-Eid merged 2 commits into
mainfrom
bench-context-settle

Conversation

@Anthony-Eid

Copy link
Copy Markdown
Contributor

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

Dropped entities are released only inside an update's effect flush, and
releases cascade across flushes. 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, letting
per-iteration state accumulate across a measurement.

Add BenchAppContext::settle, which alternates draining queued work with
update cycles until the dispatcher is idle, and call it before each
batched task iteration's setup so the previous iteration's state is
fully released outside the timed interval.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 13, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Aug 13, 2026
Its only caller is BenchAppContext::settle, and the bench_context module
only compiles with the bench feature, so builds without it failed the
dead-code lint. Also wait out the timer future's initial poll in the
is_idle unit test; it runs on a worker thread and raced the assertion.
@Anthony-Eid
Anthony-Eid added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit 0307288 Aug 13, 2026
36 checks passed
@Anthony-Eid
Anthony-Eid deleted the bench-context-settle branch August 13, 2026 19:18
HyacinthHaru pushed a commit to HyacinthHaru/z3rm that referenced this pull request Aug 16, 2026
…ies#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

(cherry picked from commit 0307288)
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…ies#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants