perf: add tinybench suite and CodSpeed CI#287
Merged
alexander-akait merged 7 commits intomainfrom Apr 17, 2026
Merged
Conversation
…Plan
- Split benchmarks by lib/ module under bench/{ignored,reducePlan,LinkResolver,watchpack}/
so CodSpeed reports them as independent groups. Each suite can be run on its
own via npm run bench:<name> or all together via npm run bench.
- Add .github/workflows/codspeed.yml using CodSpeedHQ/action to run the full
suite on push/PR so future regressions surface automatically.
- lib/index.js: skip the path-separator .replace when the input has no
backslash (35-45% faster on POSIX paths per tinybench) and fast-path
single-element ignored arrays so we don't join a one-element list.
- lib/reducePlan.js: pre-filter structural non-candidates once, shrink the
candidate set when a subtree is merged, hoist limit*0.3, and early-exit the
selection scan when a perfect (cost=0) reduction is found. Measured
~20-40% less time on medium/large plans.
https://claude.ai/code/session_012uFpZRKDYdUbCfCEMtGQzN
…ches - lib/watchEventSource.js: skip the parent-walk loop in .watch() entirely when recursiveWatchers is empty, which is always the case on Linux and the common case on OSX/Windows before the watcher limit is hit. - lib/watchEventSource.js: hoist path.basename(filePath) out of the event handler closure so it's computed once per watcher rather than on every dispatched change event. - lib/index.js: drop the redundant set.has() probe in addWatchersToSet since Set.add is already idempotent. - lib/index.js: switch Watchpack.getTimes() from Object.keys+index to a for...in walk over the prototype-less record returned by the directory watcher, avoiding a throwaway array per watched directory. - bench/ignored: add singleton-array, mixed-separator, and deep-path scenarios. - bench/reducePlan: add "barely over", aggressive, huge, very-deep, and flat-large scenarios to catch regressions in the selection loop. https://claude.ai/code/session_012uFpZRKDYdUbCfCEMtGQzN
🦋 Changeset detectedLatest commit: a17d8ba The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Every suite previously repeated the same four lines for Bench creation, CodSpeed wrapping, createRequire setup, and main-module detection. Move those into bench/helpers.mjs behind createBench/moduleRequire/runIfMain so the suite files read like the body of a single-file benchmark while still living in their own directories. The aggregate runner picks up a matching runSuites helper for the same reason. https://claude.ai/code/session_012uFpZRKDYdUbCfCEMtGQzN
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #287 +/- ##
==========================================
+ Coverage 90.20% 90.93% +0.72%
==========================================
Files 7 7
Lines 1103 1103
Branches 307 307
==========================================
+ Hits 995 1003 +8
+ Misses 95 88 -7
+ Partials 13 12 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Rewrites the benchmark infrastructure to mirror webpack/enhanced-resolve's approach: auto-discovered cases under bench/cases/<name>/index.bench.mjs with a register(bench, ctx) default export, a single bench/run.mjs entry point, and a local bench/with-codspeed.mjs bridge that talks to @codspeed/core directly (the plugin breaks on tinybench v6 private fields). - Replace @codspeed/tinybench-plugin with @codspeed/core. - Add bench/run.mjs: auto-discovers ./cases/<name>/index.bench.mjs, honours BENCH_FILTER / positional CLI filter, prints a summary table, exits non-zero on task error. - Add bench/with-codspeed.mjs: ported from enhanced-resolve; bench is returned untouched in disabled/walltime mode, run/runSync are replaced in simulation mode so each task is instrumented exactly once. - Add bench/README.md documenting layout, filter usage, and case-writing guidelines. - Rewrite each old bench file as a case directory with a register function. New cases: - ignored-match: per-shape matcher perf on POSIX paths - ignored-cross-platform: windows/mixed-separator/deep-path batches - link-resolver: cold + warm batches at three depths - reduce-plan-wide: small/medium/large/huge wide plans - reduce-plan-flat: all-siblings plans - reduce-plan-deep: deep/very-deep hierarchies - reduce-plan-fast-path: under-limit + barely-over scenarios - watchpack-construction: per-ignored-shape construction cost - Replace bench/index.mjs and bench/helpers.mjs with the new layout. - Replace the four bench:<name> npm scripts with a single `npm run benchmark` entry point that supports BENCH_FILTER; pass the V8 flags enhanced-resolve uses for CodSpeed-stable instruction counts. - Update .github/workflows/codspeed.yml to run in simulation mode. https://claude.ai/code/session_012uFpZRKDYdUbCfCEMtGQzN
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.
so CodSpeed reports them as independent groups. Each suite can be run on its
own via npm run bench: or all together via npm run bench.