Files
actual/upcoming-release-notes/faster-spreadsheet-topological-sort.md
Moshe BrevdaandClaude Opus 5.5 cf34c0e3b4 [AI] Improve cache generation perf (~22x) (#9122)
* [AI] Make spreadsheet topological sort O(V+E) instead of O(n^2)

The iterative topological sort pushed every child onto the stack at once
and, on every node pop, scanned the whole remaining stack to decrement its
parent's pending-child count. On large budgets the stack gets very tall, so
the sort was quadratic and dominated cold `loadBudget` time.

Keep the same depth-first traversal and output order, but give each stack
frame a cursor into its own neighbor list so finishing a node is O(1), and
build the result with push + a single reverse instead of unshift.

Also mark nodes visited on entry (as the recursive version before #2848
did), so a dependency cycle is skipped instead of growing the stack until
the process runs out of memory.

On a real budget (~514k cells, cold load) `loadBudget` drops from ~134s to
~6s with identical computed cell values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016C82Fnx6cnESa3HUTuM9SE

* [AI] Use plainer wording in release note

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016C82Fnx6cnESa3HUTuM9SE

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-10-08 13:58:06 +00:00

130 B

category, authors
category authors
Enhancements
mbrevda

Speed up opening a budget after downloading, importing, or resetting the cache