perf: improve CLI startup speed and local build speed - #2279
Conversation
There was a problem hiding this comment.
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.
|
|
@Souvikns @Shurtu-gal Please have a look. |
|
@neoandmatrix can you please take a look on this thanks |
|
@neoandmatrix ping pong! |
Finalizing some PRs. Will review shortly. |
|
@neoandmatrix ping pong! |
|
@neoandmatrix hey any updates? |
|
Okay, the review of this PR is taking too long. So I'm making it ready for review right away. I will be instantly available for follow-ups and requested changes. |



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:
CLI Startup Speed (Lazy Loading)
@asyncapi/parserimport insrc/apps/cli/internal/base.tstoimport typeand added a lazy getter/loader. Now, running basic commands doesn't parse@asyncapi/parserright away.ValidationService,ValidationStatus, andConversionServiceinvalidate.tsandconvert.tsuntilrun()or diagnostic handlers execute.Local Build Speed (
tsc --incremental)"incremental": trueand"tsBuildInfoFile": "./.tsbuildinfo"totsconfig.json(and added.tsbuildinfoto.gitignore). This caches AST metadata sotscdoesn't re-compile all ~200 files from scratch on minor edits.Skipping Example ZIP Downloads on Build
scripts/fetch-asyncapi-example.jsto check ifassets/examples/examples.jsonalready exists locally before fetching the 2MB zip from GitHub. I also added aFORCE_FETCH_EXAMPLES=trueenvironment flag in case anyone wants to force a fresh download.Benchmarks (Tested on my machine)
npm run build): Dropped from ~19.75s down to ~6.15s (saving ~13.6 seconds per build).time ./bin/run_bin config): Dropped from ~2.37s down to ~1.76s.Question for Maintainers
Does skipping the spec example download when
examples.jsonalready exists locally look okay to you, or would you prefer a different flag/approach for fetching examples during builds?