perf: recycle transposed grid columns in place (kill per-scroll subtree rebuild) - #138
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Env-gated (SEMISTEP_PROBE=1) probe measuring post-full-GC managed-memory floor across a long scroll workload for both the transposed and canonical recipe grids, to determine whether scrolling accumulates retained objects. Reports per-round-trip retained bytes; both surfaces measure flat. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Makes the transposed recipe grid scroll and change step-quantity without rebuilding or re-attaching column subtrees. Completes the two-part virtualization fix in one logical change.
Problem
On a large recipe (~2100 steps), scrolling the transposed grid churned GC hard. A cpu trace showed
MeasureOverride= 71% of the UI thread, dominated byTransposedColumnsPanel.Realizere-runningOnAttachedToVisualTreeCore/StyleBase.Attach/ApplyStyling/CreateCompositionVisualon every viewport crossing. Root cause (verified against Avalonia 12.0.5 source): the container'sContentPresentertore down and rebuilt the ~115-element column subtree on every recycle, becauseItemContainerGenerator.ClearItemContainerclearsContent+ContentTemplateand the typed (x:DataType)DataTemplatecan't match the intermediatenull.Fix (two complementary halves)
TransposedColumnsPanel : VirtualizingPanelkeeps containers attached (IsVisible=false+ idle stack, noRemoveInternalChildon scroll). UniformColumnWidthmakes viewport math exact. Adds focus-anchor deferral, exactOnItemsChanged,ScrollIntoView/GetControl.TransposedStepListBox : ListBoxoverridesClearContainerForItemOverride(skip base, clear onlyIsSelected) andPrepareContainerForItemOverride(re-pointContentexplicitly), plusStyleKeyOverride => typeof(ListBox). TheContentPresenternow recycles its child in place; a scroll reuse is just a DataContext re-point.Measured result (headless acceptance-gate trace, fixed workload)
MeasureOverrideinclusiveGate #2's absolute
MeasureOverridebar missed by 1.8% — a documented frame-overlap artifact in how the target was derived (the baseline attach sum nests partly outsideMeasureOverride), not a fix shortfall. Visually confirmed smooth on the live Release build. A retention probe shows a flat post-GC memory floor on both the transposed and canonical grids, so the live scroll sawtooth is normal transient GC, not a leak.Tests
Recycle-correctness (child identity, multi-select survival, no selection bleed, reset, commit-on-clearing, focus relocation), panel contract/layout/items-changed/scroll suites, an env-gated headless cpu-trace acceptance gate + speedscope analyzer, and allocation/host-reattach/retention probes. Full suite green.
Follow-ups (separate PRs)
TransposedColumnCellsHost+ pool indirection (the Host no longer detaches on scroll).TextLayout/SKFontcache for the residual render-thread text-shaping cost.🤖 Generated with Claude Code