Skip to content

text, resizable: Stop notifying state that did not change - #3418

Merged
huacnlee merged 1 commit into
mainfrom
perf/no-redundant-notifies
Oct 8, 2026
Merged

huacnlee merged 1 commit into
mainfrom
perf/no-redundant-notifies

Conversation

@huacnlee

@huacnlee huacnlee commented Oct 8, 2026

Copy link
Copy Markdown
Member

Description

Follow-up to #3407. Two more places update an entity even though nothing in it changed. Under GPUI Fast, a view that read that entity is then counted as changed and built again, even when it is retained.

  • TextViewState: a markdown text that is parsed synchronously when it is set still receives an acknowledgement (baseline_ack) from the background parser. commit_parsed_update discarded it, but only after weak_self.update, which already marked the state as updated. The receive task now checks first, with read_with and the new TextViewState::commits, and skips results that commit nothing. commit_parsed_update uses the same check.
  • ResizablePanelGroup / ResizablePanel: both report their bounds in on_prepaint on every frame they are drawn, and updated ResizableState every time, even when the bounds were the same. Every view that read the state was rebuilt on every frame. They now return early when nothing would change: same group bounds, or ResizableState::panel_size_changes (crate-private) is false.

Behaviour is unchanged: the skipped updates were no-ops.

Before / After

Measured by the new tests (gpui-fast feature), counting renders of a view that reads the state:

Case Before After
Reader of a TextViewState after the parser acknowledges a synchronous parse 2 renders 1 render
Reader of a ResizableState while its panels are redrawn at the same bounds (3 extra frames) 11 renders 5 renders

Tests

  • text::state::tests::parse_ack::acknowledging_a_parse_leaves_its_readers_retained
  • resizable::tests::redrawing_panels_where_they_were_leaves_their_readers_retained

Both fail without the fix and pass with it. cargo fmt --check and cargo clippy -p gpui-base -- --deny warnings (with and without gpui-fast) are clean. cargo test -p gpui-base --lib passes, 1323 tests. With --features gpui-fast the same 14 tests fail on main as on this branch, so this change neither causes nor fixes them.

🤖 Generated with Claude Code

A markdown text view parsed synchronously as its text is set still gets
an acknowledgement from the background parser. Committing it changed
nothing but updated the state, so GPUI Fast took every view reading the
state as changed and built it again. The receive task now skips results
that commit nothing.

Resizable panels and their group reported their bounds on every
prepaint and updated the state even when the bounds were the same, so
every view reading the state was built again on every frame. They now
update it only when the bounds or size range change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@huacnlee
huacnlee merged commit 2ef9968 into main Oct 8, 2026
16 checks passed
@huacnlee
huacnlee deleted the perf/no-redundant-notifies branch October 8, 2026 08:19
linruohan pushed a commit to linruohan/gpui-component that referenced this pull request Oct 9, 2026
…#3418)

## Description

Follow-up to longbridge#3407. Two more places update an entity even though nothing
in it changed. Under GPUI Fast, a view that read that entity is then
counted as changed and built again, even when it is retained.

- **`TextViewState`**: a markdown text that is parsed synchronously when
it is set still receives an acknowledgement (`baseline_ack`) from the
background parser. `commit_parsed_update` discarded it, but only after
`weak_self.update`, which already marked the state as updated. The
receive task now checks first, with `read_with` and the new
`TextViewState::commits`, and skips results that commit nothing.
`commit_parsed_update` uses the same check.
- **`ResizablePanelGroup` / `ResizablePanel`**: both report their bounds
in `on_prepaint` on every frame they are drawn, and updated
`ResizableState` every time, even when the bounds were the same. Every
view that read the state was rebuilt on every frame. They now return
early when nothing would change: same group bounds, or
`ResizableState::panel_size_changes` (crate-private) is false.

Behaviour is unchanged: the skipped updates were no-ops.

## Before / After

Measured by the new tests (`gpui-fast` feature), counting renders of a
view that reads the state:

| Case | Before | After |
| --- | --- | --- |
| Reader of a `TextViewState` after the parser acknowledges a
synchronous parse | 2 renders | 1 render |
| Reader of a `ResizableState` while its panels are redrawn at the same
bounds (3 extra frames) | 11 renders | 5 renders |

## Tests

-
`text::state::tests::parse_ack::acknowledging_a_parse_leaves_its_readers_retained`
-
`resizable::tests::redrawing_panels_where_they_were_leaves_their_readers_retained`

Both fail without the fix and pass with it. `cargo fmt --check` and
`cargo clippy -p gpui-base -- --deny warnings` (with and without
`gpui-fast`) are clean. `cargo test -p gpui-base --lib` passes, 1323
tests. With `--features gpui-fast` the same 14 tests fail on `main` as
on this branch, so this change neither causes nor fixes them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant