redwood
redwood copied to clipboard
[RFC]: CLI Speed Improvement
Summary
The CLI is a bit slow. It takes ~1150ms to run redwood --help
. I believe speed is part of DX and we should aim for ~300ms response time in the CLI.
Benchmark 1: node node_modules/@redwoodjs/cli/dist/index.js --help
Time (mean ± σ): 1.146 s ± 0.004 s [User: 1.139 s, System: 0.200 s]
Range (min … max): 1.141 s … 1.151 s 10 runs
Detailed proposal
We're also using yargs at Snaplet and the approach we've taken is to separate the handlers (the logic that the CLI runs) from the structure that the CLI runs. We do this by asynchronously importing the code from the handler.
But first, let's figure out what makes the CLI slow:
Normal: 1.143 s
Removing all the commands: 686.5 ms
Removing all the middleware: 119.8 ms
So with these results we can see that middleware adds an additional 500 ms (Surprizing!), and all the commands add another 600 ms.
[As I'm working on this I'll update the issue with additional information]
Are you interested in working on this?
- [x] I'm interested in working on this
In addition to the speed, I want to bring up the problem with the Prompt Windows. Why does redwoodjs's CLI raise so many Prompt Windows which only stay for a little while. Can we simply disable this?
Update, a ton of time is spent in lib/index.js
. This is where we import everything and the kitchen sink. I'm going to split the largest imports into seperate files: babel, prettier, listr
@peterp Interesting! May we know how did you make this graph?
@TristanWYL That's 0x
npx 0x -o node_modules/@redwoodjs/cli/dist/index.js --help
@TristanWYL That's
0x
Awesome! Thanks so much
Even though #6028 was merged, I'll reopen this as we plan on making more improvements.
I just had a idea to improve performance What if we create CLI as standalone built with Non Javascript Language For Example vlang ( Fastest programming language )