-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
perf: do not bind plugin hook context functions #15610
perf: do not bind plugin hook context functions #15610
Conversation
Run & review this pull request in StackBlitz Codeflow. |
IIUC Rollup intends that its plugin context can be passed around without users manually binding it. There's also a recent PR that remove the last If we want to fix the performance of this. I think we might need to rewrite the classes as closures. That might also make |
Moving to closures is probably going to be slower than what we currently have using bind functions as all the functions need to be recreated on every context creation. See this perf.link. As I was adding more complexity in the function, the closures got more and more slower. Given that Vite didn't support |
Funny how we switched sides here 😄 Thanks for testing the perf for closures, interesting to see classes winning here. Maybe we should loop in @lukastaegert about this. I'd feel more comfortable if we have Rollup acknowledge the intentional divergent here, since we'd need to get one of its upstream PR resolved still: rollup/plugins#1603 |
That is interesting indeed. |
Description
This PR reverts
Doing the 14 binds on each created plugin hook
Context
represents ~1.2% of the total work of the server using vite-dev-server-perf. Given that this feature isn't really needed, and the issue that triggered it ended up in the plugin being modified to work without binded functions I don't think we can justify the perf penalty.I think we're still in time to revert this in Vite 5.1 given that it was added in Vite 5.0 but we didn't documented it (and it is not documented in rollup either). cc @bluwy @sapphi-red
What is the purpose of this pull request?