Skip to content

perf: improve CLI startup speed and local build speed - #2279

Draft
devxdh wants to merge 3 commits into
asyncapi:masterfrom
devxdh:improve-cli-performance
Draft

perf: improve CLI startup speed and local build speed#2279
devxdh wants to merge 3 commits into
asyncapi:masterfrom
devxdh:improve-cli-performance

Conversation

@devxdh

@devxdh devxdh commented Aug 10, 2026

Copy link
Copy Markdown

Hello!

Since I hadn't gotten feedback on #2269 yet, I put together this Draft PR to show a working prototype of the startup speed improvements, along with a couple of quick build speed optimizations I found while working on it.

What's in this PR:

  1. CLI Startup Speed (Lazy Loading)

    • Converted the top-level @asyncapi/parser import in src/apps/cli/internal/base.ts to import type and added a lazy getter/loader. Now, running basic commands doesn't parse @asyncapi/parser right away.
    • Deferred loading ValidationService, ValidationStatus, and ConversionService in validate.ts and convert.ts until run() or diagnostic handlers execute.
  2. Local Build Speed (tsc --incremental)

    • Added "incremental": true and "tsBuildInfoFile": "./.tsbuildinfo" to tsconfig.json (and added .tsbuildinfo to .gitignore). This caches AST metadata so tsc doesn't re-compile all ~200 files from scratch on minor edits.
  3. Skipping Example ZIP Downloads on Build

    • Updated scripts/fetch-asyncapi-example.js to check if assets/examples/examples.json already exists locally before fetching the 2MB zip from GitHub. I also added a FORCE_FETCH_EXAMPLES=true environment flag in case anyone wants to force a fresh download.

Benchmarks (Tested on my machine)

  • Local Build (npm run build): Dropped from ~19.75s down to ~6.15s (saving ~13.6 seconds per build).
  • CLI Startup (time ./bin/run_bin config): Dropped from ~2.37s down to ~1.76s.
  • Test Suite: All 382 tests passing cleanly.

Question for Maintainers

Does skipping the spec example download when examples.json already exists locally look okay to you, or would you prefer a different flag/approach for fetching examples during builds?

@github-actions github-actions 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.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud

Copy link
Copy Markdown

@devxdh
devxdh marked this pull request as ready for review August 10, 2026 13:31
@devxdh
devxdh marked this pull request as draft August 10, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

1 participant