Repository navigation
perf(ml): P2-1 lui_flex clean-child fast lanes - #230
Merged
Merged
Conversation
…eeping Cache the inputs the flex engine re-derives per child on every parent layout pass: - resolve_specs gains a fingerprint: percent-free specs never re-resolve, percent specs only when the owner's inner dims actually changed. - Non-auto margin sums per axis are computed once at resolution (marg_row/marg_col) instead of re-walking the edge cascade. - set_position stores the seeded slot values (pos_seed_*), letting a later pass place a child without re-running the seed math. - Each node records the offer that produced its current measured dims (fin_*) plus the offers the flex-line call sites last made (prev_a_*/prev_b_*), the context those were taken under (ctx_*), and a resolution generation (res_gen) guarding staleness. The skip gates are present but disabled in this commit; all per-child work still runs, so layout results are bit-identical. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Turn the bookkeeping on: when a child is provably unaffected by its siblings' changes (identical spec resolution, identical owner context, relative flow, no auto margins, no wrapping), the parent skips the work that would re-derive identical results: - flex-basis reuse for definite or context-stable bases (guarded by was_sflex since the single-flex zero-basis depends on the sibling set) - pass-1 freeze scan skipped when there is no space to distribute - offer derivation + recursive call skipped at both flex-line sites when the offer equals the one that produced the current measured dims (fin/prev tracking, guarded by resolution generation and parent direction) - auto-margin scans skipped when no relative child has auto margins 100k-column, one child height change: ~85ms -> ~45ms per relayout pass; the two-pass frame relayout drops ~205ms -> ~91ms. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
P2-1 (deferred in #211): cut the per-node constant of
lui_flexso alocalized change no longer pays full style re-reads and measure re-calls
for every clean sibling in a recomputing column.
resolve_specsgets a fingerprint: percent-free specs resolve once,percent specs only when owner inner dims actually change; non-auto
margin sums per axis are computed once at resolution.
set_positionstores seed positions; each node records the offerthat produced its measured dims (
fin), the flex-site offers(
prev_a/prev_b), its last evaluation context (ctx), and aresolution generation guarding staleness.
bases, skip
layout_node_internalcalls whose offer provably equalsthe one that produced the current measured dims (guarded by
resolution generation and parent direction), and skip re-seeding.
scans skipped when no relative child has auto margins; the single-flex
zero-basis reuse is gated on the sibling set being unchanged.
Benchmarks (100k child column, one child's height changes)
Lui_flexrelayout passLui_flexframe two-pass relayoutLui_layout.synce2e relayoutEnd-to-end e2e measured via the perf harness (store patch + sync);
flex numbers from a standalone 100k-column benchmark.
Correctness
lui_flextests, 22lui_layouttests, and the fulldune runtestsuite (1099 checks) pass.incremental relayout results between this engine and the previous
one — zero mismatches. (Found and fixed along the way: seed staleness
across a resolve in a measure pass,
finstaleness across specre-resolution, the single-flex zero-basis sibling dependency, and
parent-direction sensitivity.)
Generated with Devin