Skip to content

perf: parse the command line once for the command being run - #322

Merged
LadyBluenotes merged 2 commits into
mainfrom
perf/cli-single-command-parse
Oct 4, 2026
Merged

LadyBluenotes merged 2 commits into
mainfrom
perf/cli-single-command-parse

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

  • cac finds the matched command by parsing the arguments one time for each registered command, and it does not stop at the match. Intent registers 15 commands, so every call parsed its arguments 15 times.
  • main() now gives cac only the command named by the first argument for the parse, then restores the full command list. cac parses one time. When the first argument is a flag or an unknown command, nothing changes.
  • The first main() call in a fresh process is 0.19 ms faster at the minimum (1.56 ms to 1.37 ms over 40 processes each). The load benchmarks, which call main() in a warm loop, are 7% to 9% faster. The list scan benchmark does not change.
  • Help output, intent help <command>, unknown commands, and exit codes are the same.
  • The workaround carries a marker that names the cac behavior and when to remove it. dist/cli.mjs grows by 181 bytes.
  • Adds a patch changeset.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr (run pnpm build:all first).

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Performance
    • CLI argument parsing now processes only the command being run, reducing parsing overhead.

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 71bf891

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

This PR includes changesets to release 1 package
Name Type
@tanstack/intent 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

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a79e84a-0c17-47f6-b0f4-444cd97ae8cd
📥 Commits

Reviewing files that changed from the base of the PR and between db658f7 and c237754.

📒 Files selected for processing (2)
  • .changeset/cli-single-command-parse.md
  • packages/intent/src/cli.ts
 __________________________________
< Code Wars Episode IV: A New Bug. >
 ----------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit c237754

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 1m 5s View ↗
nx run-many --targets=build ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-04 21:50:58 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@322

commit: 71bf891

@LadyBluenotes
LadyBluenotes merged commit 71cd72c into main Oct 4, 2026
8 checks passed
@LadyBluenotes
LadyBluenotes deleted the perf/cli-single-command-parse branch October 4, 2026 21:50
@github-actions github-actions Bot mentioned this pull request Oct 4, 2026
@codspeed

codspeed Bot commented Oct 4, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 19.83%

⚡ 4 improved benchmarks
✅ 8 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ loads a direct dependency skill 33.1 ms 25.5 ms +29.41%
⚡ loads a direct dependency from a large workspace 43.2 ms 36.1 ms +19.88%
⚡ loads direct dependency content as json 46.2 ms 38.8 ms +19.08%
⚡ checks a shipped skills tree 172.3 ms 154.4 ms +11.6%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/cli-single-command-parse (71bf891) with main (db658f7)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (7a30838) during the generation of this report, so db658f7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

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.

1 participant