Skip to content

perf(cli): the icon finder works out each set's words once and each query's forms once per pass - #12187

Merged
josephfarina merged 3 commits into
mainfrom
josephfarina/icon-finder-speed
Nov 18, 2026
Merged

josephfarina merged 3 commits into
mainfrom
josephfarina/icon-finder-speed

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Each search works out every set's icons once, with the words they match by and the forms the matcher compares, and its passes share that work. Each search starts afresh, so a set that a caller edits between searches (for example an index passed to rankIconIndex() again) answers from its new data.
  • Each query's forms (lower-case text, hyphenated id, words) are worked out once per pass instead of once per icon.
  • matchIcon() keeps its signature and calls the same matcher, so there is one implementation of the tiers.

Evidence

  • Answers before and after: identical for a fixed set of agent-style icon requests across four published icon sets (every request, every set, every returned id in order), with and without an icon set installed.
  • Time per search of one set, same box, newest canary with four published sets installed; median of three processes. "First" is the first search in a fresh process after loading the sets; "repeat" is the median of seven later searches in the same process.
Set Query Before, first / repeat After, first / repeat
Heroicons copy button clipboard icon 13.2 / 6.9 ms 9.9 / 3.9 ms
Lucide copy button clipboard icon 30.4 / 20.9 ms 20.4 / 16.2 ms
Font Awesome copy button clipboard icon 16.0 / 14.9 ms 11.7 / 9.5 ms
Meta copy button clipboard icon 26.7 / 24.7 ms 17.5 / 16.8 ms
Lucide info tooltip help circle (one pass) 14.2 / 14.3 ms 16.0 / 15.5 ms
Meta info tooltip help circle (one pass) 16.6 / 16.6 ms 15.6 / 17.9 ms

A search that needs several passes is about a third faster; a search that one pass answers costs about the same.

  • New test: repeated queries answer the same, each set object answers from its own data, and a set edited between searches answers from its new data.

Scope

Components: cli (foundation/discovery/icon-ranking.mjs)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

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

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 17, 2026 7:19am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 7:27 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 main this 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 identical Stack: #12138 → #12187 line in both bodies, rebase after #12138 lands, or reword the claim.
  • icon-ranking.mjs:548 breaks 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 (heroicons info circle tooltip leads with stop, not check-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() and matchIcon().
  • A long-running caller of stored indexes paid that cost on every query: verified. rankIconIndex() on main ranks 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 at icon.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).

Automated review (maintainer link)

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 31bc80a

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.24 MB packed (+1.7 kB); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mjs and the speed changeset, say to pass the index from a new exportIconIndex() 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 on main).
  • 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's rankTerm().
  • 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-74 loads 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 main the 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.

Automated review (maintainer link)

@josephfarina
josephfarina force-pushed the josephfarina/icon-finder-speed branch from 7073a4f to d818a4a Compare November 17, 2026 04:25

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request is reviewed as part of its stack; see the review on #12205.

Automated review (maintainer link)

@josephfarina
josephfarina force-pushed the josephfarina/icon-finder-speed branch from d818a4a to f62894b Compare November 17, 2026 06:17
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 defines rankIconIndex() 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-spec with 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.mjs and the changeset to pass new set objects (a fresh exportIconIndex() 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 main byte 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's rankTerm() and matchIcon().
  • 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 new icon() 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 to main.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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's rankTerm() and matchIcon().
  • 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 on main.
  • 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.

Automated review (maintainer link)

@josephfarina josephfarina reopened this Nov 18, 2026
@josephfarina
josephfarina merged commit af049a4 into main Nov 18, 2026
193 of 258 checks passed
@github-actions
github-actions Bot deleted the josephfarina/icon-finder-speed branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 31bc80a3 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant