You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grow the territory tree in linear time for thousands of sibling folders #82
Growing the territory tree takes longer than linear time when a directory has thousands of sibling folders. On generated repositories of N sibling modules, each with three source files and a placed test, N = 4000 takes about 5 s and N = 8000 about 28 s.
The bucket chain is the cause. When a directory has more than 8 children, 7 open and the rest wait in a "smaller folders" bucket; every split of that bucket opens 7 more and leaves a smaller bucket. N siblings therefore take about N/7 successive splits, and each split re-plans the remaining bucket, so the total work grows quadratically (rankSplits in packages/engine/src/territories/grow-tree.ts, openKids in open-kids.ts).
This predates the territory fixes; it is the remaining super-linear path in territory building.
Proposal
Cut a bucket into groups of 7 in one pass instead of chaining, or cap the chain and let the last bucket stay whole. Sort and weigh the siblings once per directory, and keep the per-folder heat and change counts so a re-plan does not recompute them.
Done when
A generated repository of 8000 sibling modules builds its territories in under 5 s.
Activity