Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: CLI Speed Improvement #6027

Closed
1 task done
peterp opened this issue Jul 23, 2022 · 8 comments · Fixed by #6028
Closed
1 task done

[RFC]: CLI Speed Improvement #6027

peterp opened this issue Jul 23, 2022 · 8 comments · Fixed by #6028

Comments

@peterp
Copy link
Contributor

peterp commented Jul 23, 2022

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?

  • I'm interested in working on this
@TristanWYL
Copy link

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?

@peterp
Copy link
Contributor Author

peterp commented Jul 24, 2022

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
image

@TristanWYL
Copy link

@peterp Interesting! May we know how did you make this graph?

@TristanWYL
Copy link

@TristanWYL Assuming you're on windows, see #5728.

Thx for letting me know!

@peterp
Copy link
Contributor Author

peterp commented Jul 25, 2022

@TristanWYL That's 0x

npx 0x -o node_modules/@redwoodjs/cli/dist/index.js --help

@TristanWYL
Copy link

@TristanWYL That's 0x

Awesome! Thanks so much

@jtoar
Copy link
Contributor

jtoar commented Jul 28, 2022

Even though #6028 was merged, I'll reopen this as we plan on making more improvements.

@jtoar jtoar reopened this Jul 28, 2022
@AjayTheWizard
Copy link

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 )

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 a pull request may close this issue.

4 participants