Repository navigation
text, resizable: Stop notifying state that did not change - #3418
Merged
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_updatediscarded it, but only afterweak_self.update, which already marked the state as updated. The receive task now checks first, withread_withand the newTextViewState::commits, and skips results that commit nothing.commit_parsed_updateuses the same check.ResizablePanelGroup/ResizablePanel: both report their bounds inon_prepainton every frame they are drawn, and updatedResizableStateevery 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, orResizableState::panel_size_changes(crate-private) is false.Behaviour is unchanged: the skipped updates were no-ops.
Before / After
Measured by the new tests (
gpui-fastfeature), counting renders of a view that reads the state:TextViewStateafter the parser acknowledges a synchronous parseResizableStatewhile its panels are redrawn at the same bounds (3 extra frames)Tests
text::state::tests::parse_ack::acknowledging_a_parse_leaves_its_readers_retainedresizable::tests::redrawing_panels_where_they_were_leaves_their_readers_retainedBoth fail without the fix and pass with it.
cargo fmt --checkandcargo clippy -p gpui-base -- --deny warnings(with and withoutgpui-fast) are clean.cargo test -p gpui-base --libpasses, 1323 tests. With--features gpui-fastthe same 14 tests fail onmainas on this branch, so this change neither causes nor fixes them.🤖 Generated with Claude Code