-
Notifications
You must be signed in to change notification settings - Fork 220
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
Improve performance with NPM package #146
Conversation
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook" | ||
then | ||
eval $dir/node_modules/@arkweid/lefthook/bin/$cmd |
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.
You can see we're checking if the binaries in the NPM packages exists before the Ruby part. This seems a bit odd at the first glance… but it improves performance for NPM packages because running bundle exec
is quite slow. And adding a simple file existence check before the Ruby part is not an issue: the check is fast enough to not penalize Ruby users.
Great work! Will check it soon. |
@nesk
Could you look at? |
Sorry, I should have been more careful. Indeed, we should switch to Do you want a PR for this? |
@nesk could we switch syntax to |
After a bit of searching, unfortunately I think we have two ways to manage this:
I'm really sorry I messed up your codebase… 😞 |
@nesk Here a docker file for Discourse. I test new builds for this one.
Now apply changes for npm package:
|
See #154 for a bugfix 🙂 |
Using lefthook through the NPM package causes performance issues, because NPX is a bit slow to start and execute each time lefthook is invoked. This can especially being seen when doing rebases with dozens of commits.
Here's a basic benchmark between native binary and NPM:
If you rebase some commits, it will take ~9 times longer to finish rebasing with NPM vs native binary.
This PR makes the hooks search for the final binaries by themselves, rather than using the
npx
command (which is now only used as a fallback).Here's a benchmark comparing native binary, NPM before this PR, and NPM after this PR:
You can see this PR makes NPM as fast as the native binary.