Skip to content

perf: add tinybench suite and CodSpeed CI#287

Merged
alexander-akait merged 7 commits intomainfrom
claude/add-performance-benchmarks-1Jwmm
Apr 17, 2026
Merged

perf: add tinybench suite and CodSpeed CI#287
alexander-akait merged 7 commits intomainfrom
claude/add-performance-benchmarks-1Jwmm

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

@alexander-akait alexander-akait commented Apr 16, 2026

  • 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: or all together via npm run bench.

claude added 2 commits April 16, 2026 15:30
…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-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2026

🦋 Changeset detected

Latest commit: a17d8ba

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

This PR includes changesets to release 1 package
Name Type
watchpack 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

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 16, 2026

CLA Not Signed

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
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.93%. Comparing base (3432c27) to head (a17d8ba).
⚠️ Report is 3 commits behind head on main.

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     
Flag Coverage Δ
integration 90.93% <ø> (+0.72%) ⬆️

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.

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
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2026

@alexander-akait alexander-akait changed the title perf: add tinybench suite, CodSpeed CI, and optimize ignored + reducePlan perf: add tinybench suite and CodSpeed CI Apr 17, 2026
@alexander-akait alexander-akait merged commit 6f582c7 into main Apr 17, 2026
48 of 49 checks passed
@alexander-akait alexander-akait deleted the claude/add-performance-benchmarks-1Jwmm branch April 17, 2026 13:21
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