Repository navigation
perf: replace unbounded spreads and quadratic layout lookups - #21
Merged
Merged
Conversation
Compute geometry bounds with linear helpers instead of argument spreads, and index node positions plus link endpoints once per layout. Scene geometry and diagnostics remain unchanged.
Describe the removed argument spreads and the precomputed node/link indexes precisely, and note the helper empty-input fallbacks.
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
Fixes
CONFIRMED-FINDINGS.mditems 5 and 6 (grouped because both are layout-scaling changes that must not alter geometry).src/layout.ts: adds linearmaxOf/minOfhelpers and removes argument spreads over links, nodes, stages, routes and labels. Precomputes node input indexes and groups links byfrom/toonce so port construction no longer runsindexOf/filterper node. Port groups are copied before sorting, preserving input order.src/paths.ts:describe()computes length and x/y bounds in one linear pass instead of four spreads.tests/paths.test.ts: regression callsdescribe()with 200,000 points and checks bounds withoutRangeError; the old implementation throwsRangeErroron this input.CHANGELOG.md: one scoped[Unreleased] / Fixedentry.Geometry equivalence
All five benchmark scene hashes match
devexactly before and after:c4c086c4…557a9964598e2b…a668dee1de1c7…68780bea2886d…b7e2edbd6da6…f3062The reviewer also compared 301 additional scenes (demo graphs, widths,
minLinkWidth, edge nodes, empty/zero-link graphs) with zero mismatches.Performance
Raw full-benchmark timings were noisy on the shared host and are not a reliable before/after comparison. The controlled same-process alternating stress A/B is the meaningful evidence:
dev105.29 ms vs PR 99.75 ms, −5.3%, across 20 alternating pairs.Verification
npm run format— passednpm run typecheck— passednpm run lint— passednpm test— 153 tests passednpm run build— passednpm run stress— identical scene hash and crossingsnpm run benchmark— all five fixture hashes matched before/afterNotes
Browser tests were not run to avoid the shared Playwright port. No geometry, ordering or diagnostics were intentionally changed. Some other quadratic-looking scans remain outside the specific item-6 lookups; the changelog is scoped accordingly.