improvise-h6z1: one fold memo per grid build, keyed by fold key and span
viewport::grid_body makes one FoldMemo and passes it to every cell and total through GridLayout::evaluate_in / column_total, so a fold row's formula chain is evaluated once across the row (9, not 45). The bench gains a folded five-formula chain case; stored-only grids are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
+12
-2
@@ -929,8 +929,18 @@ every member. Five decisions:
|
||||
without the memo, about 60 ms with it, and about 10 ms on gh/main. gh/main
|
||||
was cheap because it read the members out of the formula cache, which is
|
||||
what gave the wrong ratios. The remaining ~6× is each column's cell
|
||||
re-deriving the chain below it (45 evaluations per row where 9 would do). A
|
||||
memo scoped to the whole grid would remove it; it is not built.
|
||||
re-deriving the chain below it (45 evaluations per row where 9 would do).
|
||||
**The memo is now shared across one grid build** (improvise-h6z1).
|
||||
`viewport::grid_body` makes one `FoldMemo` and passes it through
|
||||
`GridLayout::evaluate_in` and `column_total` for every cell and total, so a
|
||||
fold row's chain is evaluated 9 times, not 45. A memo is valid only for the
|
||||
model state it read. That is why it is made per build and never stored on
|
||||
`GridLayout`, which outlives cell writes.
|
||||
The memo is keyed by the fold key **and** the span's categories. Within one
|
||||
grid build the span half cannot yet differ for one key, because a cell's key
|
||||
always names the row categories and a total's never does. It is kept because
|
||||
`evaluate_spanning_in` is public, and a caller sharing one memo across two
|
||||
spans would otherwise read the wrong fold. No test can see it today.
|
||||
- **A fold covers the members the grid draws** (improvise-f2oo). Hidden members
|
||||
are not in it. So a fold is exactly the rows it replaces, the total of a
|
||||
column's total does not move on `z`, and a group whose every member is hidden
|
||||
|
||||
Reference in New Issue
Block a user