Skip to content

perf(alias): avoid per-resolve split("*") in AliasUtils scan#529

Merged
alexander-akait merged 2 commits intomainfrom
claude/add-performance-benchmarks-d00HP
Apr 17, 2026
Merged

perf(alias): avoid per-resolve split("*") in AliasUtils scan#529
alexander-akait merged 2 commits intomainfrom
claude/add-performance-benchmarks-d00HP

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

AliasPlugin's per-resolve scan (aliasResolveHandler) called
item.name.split("*") for every alias option on every resolve, allocating
an array on each iteration even though almost all aliases in practice
contain no * and the split's result was immediately discarded.

Replace with a cheap indexOf("*")-based check that only computes the
prefix/suffix slices when the wildcard branch actually fires. Semantics
match the original split("*").length === 2: wildcard iff exactly one
* is present in item.name.

Measured locally via the benchmark suite (wall-clock, n=10):
alias-wildcard-scan 471 -> 552 ops/s (+17.1%)
large-alias-list 836 -> 952 ops/s (+13.9%)

Adds a new alias-wildcard-scan benchmark case that stresses this
decision with 100 non-matching aliases + 1 wildcard + 1 exact match so
the wildcard-detection cost shows up cleanly on CodSpeed, separately
from the fixture-IO exercised by large-alias-list.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 16, 2026

CLA Not Signed

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2026

🦋 Changeset detected

Latest commit: 285bcb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
enhanced-resolve Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.51%. Comparing base (6637632) to head (285bcb4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #529   +/-   ##
=======================================
  Coverage   96.51%   96.51%           
=======================================
  Files          50       50           
  Lines        2639     2640    +1     
  Branches      805      806    +1     
=======================================
+ Hits         2547     2548    +1     
  Misses         77       77           
  Partials       15       15           
Flag Coverage Δ
integration 96.51% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2026

Merging this PR will improve performance by 55.12%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
✅ 50 untouched benchmarks
🆕 1 new benchmark

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 alias-wildcard-scan: 100+1 wildcard + 1 exact N/A 3.9 ms N/A
pathological-deep-stack: alias chain of 50 (warm) 24.5 ms 19.1 ms +28.3%
deep-hierarchy: bare specifier from 10-deep dir (warm) 2.9 ms 2.4 ms +21.23%
large-alias-list: 50+8 aliases, match near end 2.7 ms 2.2 ms +23.77%
multiple-modules: shared + vendor + node_modules (warm) 1.7 ms 1.4 ms +24.93%
stack-churn: 4x60 alias chains, 20 resolves 161.2 ms 103.9 ms +55.12%

Comparing claude/add-performance-benchmarks-d00HP (285bcb4) with main (6637632)

Open in CodSpeed

AliasPlugin's per-resolve scan (`aliasResolveHandler`) called
`item.name.split("*")` for every alias option on every resolve, allocating
an array on each iteration even though almost all aliases in practice
contain no `*` and the split's result was immediately discarded.

Replace with a cheap `indexOf("*")`-based check that only computes the
prefix/suffix slices when the wildcard branch actually fires. Semantics
match the original `split("*").length === 2`: wildcard iff exactly one
`*` is present in `item.name`.

Measured locally via the benchmark suite (wall-clock, n=10):
  alias-wildcard-scan  471 -> 552 ops/s (+17.1%)
  large-alias-list     836 -> 952 ops/s (+13.9%)

Adds a new `alias-wildcard-scan` benchmark case that stresses this
decision with 100 non-matching aliases + 1 wildcard + 1 exact match so
the wildcard-detection cost shows up cleanly on CodSpeed, separately
from the fixture-IO exercised by `large-alias-list`.
@alexander-akait alexander-akait force-pushed the claude/add-performance-benchmarks-d00HP branch from 3196401 to e6d257d Compare April 17, 2026 14:14
@alexander-akait alexander-akait merged commit 68f8a15 into main Apr 17, 2026
33 of 34 checks passed
@alexander-akait alexander-akait deleted the claude/add-performance-benchmarks-d00HP branch April 17, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants