-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
feat(cli): build --profile #10719
feat(cli): build --profile #10719
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @ArnaudBarre, I think this feature makes now a lot more sense for build than its current state for dev.
Looks like it is currently only measuring the config and buildStart hooks for plugins and the HTTP server start during dev. At one point it was also measuring pre-bundling of dependencies but that was now moved after the server start. Maybe we should stop the profiler during dev once every statically imported module has been processed, deps prebundled, and the server is idle. We have that signal now. But this could be discussed in another PR.
I though of that and was thinking of a dumb "setTimeout 10_000" but that not ideal. What is this signal? Or maybe we should only write on server exit so that people can profile HMR? |
The signal is currently tied to the optimizer here. We use it during dev to delay sending to the browser optimized dependencies that may be invalidated if there is a missing dependency. We could extract the But interesting idea about profiling HMR. Maybe by default having the profiler stop when the server exits is more useful. Another idea is to have something like #9673 and a shortcut to start and stop the profiler at any point during the server run. Or maybe having Vite output several profiles, like:
|
Thanks pour the pointers. I will update the PR this evening. Interesting idea for using the current shortcuts PR pour profiling HMR. Do you want to go forward with this PR? I did a review. I like some of the possibilities, even if it could mean a |
Thanks for reviewing #9673 @ArnaudBarre. I think we shouldn't block this PR waiting for it. Let's address Blue comment to stop at finally in both dev and build, and we can merge this one. We can then work the details of #9673 without additional shortcuts, it would be good to get it in Vite 4. And once that one is merged, we can propose additional shortcuts (like start/stop profiling). I hope we don't need that new label though 😅 |
I added also preview because that's cheap I looked at the onCrawlEnd but it would be too hacky to put it there I think. Maybe exposing something like: server.onInitialLoadEnded(cb: () => void) Not the best name, but I would like both something that is not tied to the optimiser and only call once. |
This will allow to profile
vite build
to detect performance issues in plugins only applied at build time.Usage example:
![Screenshot 2022-11-09 at 04 14 30](https://user-images.githubusercontent.com/14235743/200729584-1018c142-6653-4e1f-a7c5-19da8ac92048.png)
![Screenshot 2022-11-09 at 04 14 56](https://user-images.githubusercontent.com/14235743/200729555-44fef818-531c-4b81-bd63-fc3fd0ee2f87.png)
Note: There is a small regression on the initial build message in Vite 4