Repository navigation
perf(cli): the icon finder works out each set's words once and each query's forms once per pass - #12187
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the AST-084 FR6 additions this diff carries from #12138: score-20 word matches for queries of several words that nothing else answers, and export names read as their words. An engineering owner records the decision by commenting /approve-spec with this pull request's full head SHA. The author can do this, because they are an engineering owner.
Blocking findings:
- The description says FR6 ranking and product behavior are unchanged, but against
mainthis diff adds the word-match tier and export-name reading (22 of 43 phrase and export-name probe queries answer differently), so declare the stack with an identicalStack: #12138 → #12187line in both bodies, rebase after #12138 lands, or reword the claim. icon-ranking.mjs:548breaks ties among equal-weight word matches by subtracting the count of carried words from the id's part count, so an icon that carries a query word only through a tag or a definition counts as fully named (heroiconsinfo circle tooltipleads withstop, notcheck-circle), against FR6's "fewer id parts the query does not name"; count the id parts no query word names, and add a test where the shared word comes from a tag.
The speed-up itself holds up: answers match #12138's head on every probe query, and the icon test suites pass. Optional: say in rankIconIndex()'s doc that a stored index is not watched for edits, because the new cache keeps answering from an index's first read.
Claims and files checked
Review mode: full; reason: no-earlier-review
Description claims
- Each pass used to rebuild every icon's words and the query's forms for every icon: verified in the previous
rankTerm()andmatchIcon(). - A long-running caller of stored indexes paid that cost on every query: verified.
rankIconIndex()onmainranks the caller's own set objects, so it benefits once merged. - FR6 ranking is unchanged for every query and set: false against
main, because word matches and export-name reading are added. True against #12138's head (43 of 43 probe queries identical). - Set data is worked out once per set object in a
WeakMap, and a new set object gets its own entry: verified (icon-ranking.mjs:612-637, test aticon.test.mjs:668). - Query forms are worked out once per pass: verified (
icon-ranking.mjs:646). matchIcon()keeps its signature and the same matcher: verified (icon-ranking.mjs:142-144).- Answers are identical before and after on published sets: corroborated on synthetic sets only.
- Timing table: the direction is corroborated (warm 6.3 to 2.3, 18.9 to 4.3 and 35.8 to 5.2 ms), but the exact figures were not reproduced.
- The new test for repeated queries and per-object data: verified, and it passes.
- No public API change: verified.
- No product behavior change: false against
main. - Product changes split out: false as the diff stands, because it carries #12138.
- No internal context: verified.
- The listed test command: verified; a superset passes (62 files, 1,416 tests).
Changesets
icon-finder-speed, faster ranking with unchanged answers: verified against #12138's head.icon-search-words, score-20 word matches, rarest words first, a mapped definition's words counted twice, unknown words counting for nothing, export names read as words, answered queries keeping their answers: verified in code, tests and probe. Shipping it waits on the FR6 decision.
Files
.changeset/icon-finder-speed.md: clear..changeset/icon-search-words.md: accurate; waits on the FR6 decision.docs/specs/AST-084-icon-sets/spec.md: the FR6 additions wait on an owner decision, and the code contradicts the stated tie rule.packages/cli/api/icon/icon.doc.mjs: matches the code; waits on the FR6 decision.packages/cli/api/icon/icon.test.mjs: passes, but the tie test cannot tell the two tie rules apart.packages/cli/foundation/discovery/icon-ranking.mjs: tie key at line 548 (blocking); cache contract (non-blocking).
PR Analysis Report🔎 Preview ·
|
11b94b0 to
7073a4f
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the AST-084 FR6 additions this diff carries from #12138 (the Stack: line is missing from #12205's body, so this pull request is reviewed alone against main).
What needs settling:
- The score-20 word-match tier in the search answer: which icons count as carrying a word, set order first, then the summed log weight with mapped-definition words counted twice, then fewer unnamed id parts, then id. Word matches never appear in
<set>/<id>suggestions or fitting definitions. - Reading a word written as an export name (
SearchIcon) as its words, with the typed reading winning a tie. rankIconIndex()keeping what it works out from each index set object, so a set edited in place keeps its first answers.
An engineering owner records the decision by commenting /approve-spec with this pull request's full head SHA, and the author can do this as an engineering owner. Both earlier findings are fixed, and answers match #12138's head on every query checked. CI at this head stopped because CI was full, so it needs a re-run.
- Optional: in
rankIconIndex.doc.mjsand the speed changeset, say to pass the index from a newexportIconIndex()call. An edited set object inside a new index object still answers from its old data.
Claims and files checked
Review mode: full; reason: rebase
- Claim: Speed changeset: each set's searchable words are worked out once per set object and each query's forms once per pass. Verified (
icon-ranking.mjs:635-660,:668-677). - Claim: Speed changeset: answers are unchanged. Verified against #12138's head: 96 queries over four set lists, with and without word matches.
- Claim: Speed changeset:
rankIconIndex()reads each set object as unchanging data, so pass a new index object. Verified as behavior; the wording is imprecise (non-blocking note). - Claim: Search changeset: a query of several words that nothing answers returns word matches at score 20, the project's set first and rarer words first. Verified (
icon-ranking.mjs:532-597,icon.test.mjs:632-690). - Claim: Search changeset: definition-name words count twice and a word no icon carries counts for nothing. Verified (
icon-ranking.mjs:563-566,:599-611). - Claim: Search changeset: word matches appear only in the search answer and only where nothing answered before. Verified (
search.mjs:114,:170; every changed query was empty onmain). - Claim: Search changeset: an export name reads as its words, and the better-scoring reading answers. Verified (
icon-ranking.mjs:502-506,icon.test.mjs:568-600). - Claim: Description: each pass rebuilt every icon's words and query forms. Verified in
main'srankTerm(). - Claim: Description: the FR6 ranking is unchanged against #12138's head. Verified, as above.
- Claim: Description: a new
icon()call reads the sets again and gets its own cache entry. Verified (search.mjs:67-74loads sets per call; discovery keeps no cache). - Claim: Description:
matchIcon()keeps its signature and calls the same matcher. Verified (icon-ranking.mjs:145-147). - Claim: Description: the
rankIconIndex()doc states the set-object rule. Verified (rankIconIndex.doc.mjs:20). - Claim: Description: timing table. Consistent in direction (warm rankings 3 to 10 times faster over about 2,600 icons); the four published sets were not reproduced.
- Claim: Description: a new test covers repeated queries and per-object data. Verified (
icon.test.mjs:723-730). - Claim: Description: no intended API or behavior change against #12138. Verified; against
mainthe diff carries #12138's behavior change. - File:
.changeset/icon-finder-speed.md: non-blocking wording note. - File:
.changeset/icon-search-words.md: clear. - File:
docs/specs/AST-084-icon-sets/spec.md: FR6 additions wait on an engineering owner. - File:
packages/cli/api/icon/icon.doc.mjs: clear. - File:
packages/cli/api/icon/icon.test.mjs: clear. - File:
packages/cli/api/icon/rankIconIndex.doc.mjs: non-blocking wording note; the set-object rule is in the owner decision. - File:
packages/cli/api/icon/search/search.mjs: clear. - File:
packages/cli/foundation/discovery/icon-ranking.mjs: clear; its word tier waits with the FR6 text.
7073a4f to
d818a4a
Compare
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #12205.
…uery's forms once per pass
d818a4a to
f62894b
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about one caller contract; the ranking change itself holds up, with answers identical to main on every query checked and the icon test suites passing. #12205's Stack: line still lists #12138 and differs from this one, so this pull request is reviewed on its own.
What needs settling:
rankIconIndex()now keeps what it works out from each set object across calls, and its doc tells callers that a set object does not change; the record that definesrankIconIndex()does not say whether a caller may edit an index's sets between calls, and with this change an edited set answers partly from its first read (an added icon is not found). An engineering owner decides whether that is the contract or whether the kept data should last only for one ranking call, and records it by commenting/approve-specwith this pull request's full head SHA; the author can do this as an engineering owner.
Optional:
- If the contract stays, say in
rankIconIndex.doc.mjsand the changeset to pass new set objects (a freshexportIconIndex()result or a parsed copy): a new index object around the same edited sets still answers from the old data.
Claims and files checked
Review mode: full; reason: rebase
- Changeset: the icon command ranks faster because each set's words are worked out once per set and the query's forms once per pass. Verified (
icon-ranking.mjs:640-665,:674; faster on a 6,000-icon set). - Changeset: answers are unchanged. Verified: 3,687 answers over heroicons and lucide sets match
mainbyte for byte. - Changeset:
rankIconIndex()reads each set object as data that does not change. Verified (icon-index.mjs:136,icon-ranking.mjs:646-648). - Changeset: pass a new index object when a set changes. Incomplete: a new index object around the same edited sets still answers from the old data (optional wording fix).
- Changeset category: an
[experimental]patch for the CLI. Verified against the experimental-change rule. - Description: each pass rebuilt every icon's words and the query's forms per icon. Verified in
main'srankTerm()andmatchIcon(). - Description: a several-word query takes up to three passes. Narrower than the code, which runs up to four (as typed, without filler words, with export names split, word stage); harmless.
- Description: a long-running
rankIconIndex()caller paid that cost on every query. Verified. - Description: ranking is unchanged for every query and set. Verified by the same comparison.
- Description: data is kept per set object in a
WeakMap, and a newicon()call gets its own entry. Verified (icon-ranking.mjs:640;icon()loads a new project and its sets per call). - Description: query forms are worked out once per pass. Verified (
icon-ranking.mjs:674). - Description:
matchIcon()keeps its signature and the same matcher. Verified (icon-ranking.mjs:147-149). - Description: answers are identical on four published sets. Corroborated on two library-built sets; the published sets were not available.
- Description: the
rankIconIndex()doc states the set-object rule. Verified (rankIconIndex.doc.mjs:20); the rule waits on an engineering owner. - Description: timing table. Direction corroborated (repeat rankings 3 to 5 times faster on 6,000 icons); the exact figures were not reproduced.
- Description: a new test covers repeated queries and per-object data. Verified (
icon.test.mjs:736-743); it passes. - Description: no public API change. Verified. No product behavior change: true for
icon()and for indexes that are not edited; not for an index edited in place, which is the open decision. - Description: product changes were split out. Verified: the tie-order change is in #12205.
- Description: no internal context. Verified.
- Description: the listed test command. Verified; a superset passes (63 files, 1,434 tests).
- File:
.changeset/icon-finder-speed.md: optional wording note. - File:
packages/cli/api/icon/icon.test.mjs: clear. - File:
packages/cli/api/icon/rankIconIndex.doc.mjs: the set-object sentence waits on an engineering owner; optional wording note. - File:
packages/cli/foundation/discovery/icon-ranking.mjs: clear; answers identical tomain.
…one search's passes only
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because its run was refused while CI was full, so the CI jobs need a re-run. The ranking change keeps every answer identical to main on every query checked, and the worked-out data now lasts one search, so a caller that edits an index's sets between calls sees its edits. Nothing else needs to change. #12205's Stack: line still differs from this one, so this pull request is reviewed on its own.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Changeset: the icon command ranks faster because each search works out every set's words once and each query's forms once per pass. Verified (
icon-ranking.mjs:496-515,:651-670,:680); faster on a 2,296-icon set. - Changeset: answers are unchanged. Verified: 13,344 ranking results identical to
main. - Changeset category: an
[experimental]patch for the CLI. Verified against the experimental-change rule. - Description: each pass ranks every icon, and a several-word query takes up to four passes. Verified (
icon-ranking.mjs:496-515). - Description: each pass rebuilt every icon's words and re-derived the query's forms per icon. Verified in
main'srankTerm()andmatchIcon(). - Description: ranking is unchanged for every query and set. Verified by the same comparison.
- Description: each search works out each set once, its passes share it, and an edited set answers from its new data. Verified (
icon-ranking.mjs:497-498); an edited set answers as onmain. - Description: query forms are worked out once per pass. Verified (
icon-ranking.mjs:680). - Description:
matchIcon()keeps its signature and the same matcher. Verified (icon-ranking.mjs:147-149). - Description: identical answers on four published sets. Corroborated on two sets built from a published icon library's names; the published sets themselves were not available.
- Description: timing table. Direction corroborated (multi-pass searches about 40% faster); the exact figures were not reproduced.
- Description: a new test covers repeated queries, per-object data and a set edited between searches. Verified (
icon.test.mjs:736-747); it passes. - Description: no public API, product behavior or policy change. Verified.
- Description: product changes were split out. Verified: the tie-order change is in #12205.
- Description: no internal context. Verified.
- Description: the listed test command. Verified: 6 files, 191 tests pass.
- File
.changeset/icon-finder-speed.md: clear. - File
packages/cli/api/icon/icon.test.mjs: clear. - File
packages/cli/foundation/discovery/icon-ranking.mjs: clear.
Stack: #12187 → #12205
Maintainer impact
The icon finder ranks every icon of every searched set in each pass, and a query of several words takes up to four passes (as typed, without filler words, with export names read as words, then the word stage). Each pass rebuilt every icon's words (its own words plus the words of the definitions it is mapped to) and re-derived the same query forms for every icon, so a phrase search spent most of its time rebuilding the same data.
Intended invariant
AST-084 FR6 ranking is unchanged: the same matches, scores, reasons and order for every query and set.
Change
rankIconIndex()again) answers from its new data.matchIcon()keeps its signature and calls the same matcher, so there is one implementation of the tiers.Evidence
copy button clipboard iconcopy button clipboard iconcopy button clipboard iconcopy button clipboard iconinfo tooltip help circle(one pass)info tooltip help circle(one pass)A search that needs several passes is about a third faster; a search that one pass answers costs about the same.
Scope
Components: cli (
foundation/discovery/icon-ranking.mjs)Testing
npx vitest run --project node packages/cli/api/icon/icon.test.mjs packages/cli/clients/cli/commands/icon.test.mjs packages/cli/foundation/discovery/icon-set-checks.test.mjs packages/cli/foundation/discovery/template-icons.test.mjs packages/cli/api/icon/search/icon-index.test.mjs packages/cli/foundation/discovery/icon-set-writer.test.mjs