Repository navigation
fix(cli): searchCore reuses the gathered candidates, as search does - #8512
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Recommended for approval: searchCore now ranks the catalog search already reuses, its answers are unchanged, and the new test fails before the change and passes after it. Worth one line in the changeset or description: each one-shot astryx build now records every read of its single gather, which measured about 9% (roughly 200 ms) slower per invocation, the same cost one-shot astryx search already pays in exchange for a much faster repeated build in a long-running process.
[Automated review]
7db035e to
cfad6d6
Compare
There was a problem hiding this comment.
Changes requested: the code change is sound and its answers are unchanged, but one sentence of the changeset needs rewording before approval.
- Newly live check:
.changeset/cli-search-core-reuse.mdsays a long-running caller that "builds or searches repeatedly" no longer re-reads every catalog, butsearchalready reused its gather before this change, so name only what changed, for example "A long-running caller that builds repeatedly, or builds after a search in the same folder, no longer reads every component, hook, doc, template and theme again for each build."
CI has not run on this head yet: mark the pull request ready for review, and a maintainer adds the ci:run label so CI runs.
[Automated review]
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] The lexical ranker behind `astryx build`'s search ranks the candidates search gathers, reused the same way. A later query in the same folder gathers again only when an input changed. A long-running caller that builds or searches repeatedly no longer reads every component, hook, doc, template and theme again for each query. Results are unchanged. |
There was a problem hiding this comment.
Newly live check: search already reused its gather before this change (a second search loads nothing either way), so "builds or searches repeatedly" claims a change for search callers that did not happen. Suggested wording: "A long-running caller that builds repeatedly, or builds after a search in the same folder, no longer reads every component, hook, doc, template and theme again for each build."
There was a problem hiding this comment.
Fixed in 712626c, worded to what changed. A probe counting Project.load in the second of two queries shows three pairs go from 5 to 0: a build after a build, a build after a search, and a search after a build (build's gather now fills the shared reuse). A search after a search stays at 0, so the changeset no longer claims it.
searchCore, the ranker astryx build ranks with, called gatherCandidates on every query: about 0.75 s of listing and reading every domain. search reads the same candidates through gatherCandidatesReused, which checks every input for changes. searchCore now reads through the same reuse, and rankLexical only reads the catalog, so answers are unchanged. A second searchCore in the same folder with unchanged inputs loads the project 0 times instead of 5.
cfad6d6 to
712626c
Compare
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet.
searchCore now ranks the catalog search already reuses, its answers are unchanged, the new test fails without the change, and the reworded changeset names only what changes. Next, mark the pull request ready for review, and a maintainer adds the ci:run label so CI runs.
[Automated review]
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
searchCore now ranks the catalog search already reuses, so a repeated build, or a search after a build, in the same folder stops gathering every domain again. Its answers are unchanged, the new test fails without the change, and the changeset names only what changes.
[Automated review]
User impact
searchCore, the lexical ranker thatastryx buildranks with, gathered every candidate again on every query: about 0.75 s of listing and reading every domain.searchreads the same candidates through a reuse that checks each input for changes, so a long-running caller paid the gather once there but on every query here._main-searcher.test.mjscompares the two query by query. Its whole-name case takes about 2.8 s alone and fails its 30 s limit on a busy machine.Problem and solution fit
searchCoreReadcalledgatherCandidates(options).searchReadcallsgatherCandidatesReused(options)(feat(docsite): search panel runs the CLI's own search #7830), which checks every file the gather read and every folder it listed (fix(cli): a long-running caller sees an edit to a doc file it already read #7998), and gathers again when one changed.Project.loadcalls total about 25 ms of a 650 ms call; the gather is the rest.rankLexicalonly reads the catalog, so the two rankers can share it.Expected behavior and authority
The reuse contract in
gatherCandidatesReused: a later search in the same folder, for the sametype, ranks the candidates an earlier search gathered while none of their inputs changed. The lexical ranker answers the same either way.Smallest restoration
searchCoreReadreads throughgatherCandidatesReused. One line plus its JSDoc.Evidence
_adapter.test.mjscase holds the inputs unchanged and countsProject.loadcalls during a secondsearchCore('Button')in the repository: 5 onmain._main-searcher.test.mjsalone, 2 runs per side: "answers a whole-name query exactly as the lexical ranker does" takes 2.87 s and 2.77 s onmain, 0.67 s twice with the fix. "never returns more results or more bytes than the lexical ranker" goes from 6.69 s and 6.57 s to 2.48 s and 2.51 s.mainfails the whole-name case at 36.0 s and 36.1 s, over its 30 s limit. With the fix it takes 7.1 s and 8.0 s, and the file passes both runs.mainand 29.2–29.9 s with the fix at that load. This change does not touch that cost.Project.loadcalls made by the second of two queries in one process, in the repository):searchCoreaftersearchCore,searchCoreaftersearch, andsearchaftersearchCoreload the project 5 times each onmainand 0 times here.searchaftersearchloads it 0 times on both._main-searchercases still compare both rankers query by query, and the existing reuse cases (an edited input, another folder or type, a linked package) pass.Project.loadcount.Scope
Testing
At cfad6d6 on
main8516fb5. The head, 712626c, changes only the changeset's wording; thereapi/search/_adapter.test.mjspasses 6 of 6:vitest run --project nodeonapi/searchandapi/build: 21 files, 273 tests pass.CPUQuota=100%holds the vitest run and 8node -e 'for(;;){}'loops. Sides alternate first and last, withpnpm install --frozen-lockfileat each revision (exit 0). Times are vitest's per-case durations.eslint(CI=true),pnpm lintand Prettier pass on the changed files.pnpm review:pre: 0 findings.