Repository navigation
perf(engine): parse the project once for the page and resource indexes - #192
Merged
Merged
Conversation
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
The page index and the resource index each parsed the whole app into their own ts-morph project. They did it after every write, and again after every outside edit. The editor reads both right after each save: table usage, the page list and the table list. So each save paid two full parses.
indexedProject()keeps the stamp check the two indexes had: a new parse once a file it read was written since, or after either index is invalidated. Each index rescans when the parse it read is replaced.Evidence
Evidence level: benchmark of the engine operations, plus an end-to-end profile in the dashboard.
Workload: the repository playground in a fixture. An outside edit of the Board page is followed by what the editor reads after a save: table usage,
ListPagesandListResources. Sides run interleaved, 5 runs each.In the dashboard,
GET /api/builder/pagesduring the editor's open drops from about 550 ms to 15 ms./resourceshas already parsed the shared project by then.Cumulative impact: one parse less after every save and on every editor open, about 0.5 s of server CPU each time. The backend's event loop is blocked during a parse, so other requests wait too.
The engine specs (
test:unit) pass: 523 passing.Verification
pnpm run checkspasses. Main failssync:checkon a stale compat row inpackages/dms-builder/README.md(interface-dms-builder 0.4.0, published 0.4.1), so a separate commit syncs it. It is the same line build(deps): move to @antelopejs/tooling-configs 0.5.0 #190 carries, byte for byte, so whichever of the two lands second has an empty or trivial conflict there.smoke,blocks(3),pages(3) andresources(4) journeys pass. Dashboard save, Save click to the server's answer, 15 saves per side: 2325 ms (2010–3792) on main, 630 ms (440–1102) with the three PRs.formal-page-save: the same output on main and on this branch. The only finding is the recorded F2 (Moving a page with an unsaved draft lets the next Save overwrite an outside change without the stale banner #163), which none of these lines touch. The gate flags the covered code's emit as changed.Merge Danger
Door: two-way.
Blast Radius: page and resource listings.
Invalidating one index now also rescans the other:
RefreshSourceIndexreads resources again too. Neither scanner edits the project, and every write opens its nodes from the writable project.