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

Option to fully disable LFS hooks #879

Merged
merged 4 commits into from
Nov 28, 2024

Conversation

zachahn
Copy link
Contributor

@zachahn zachahn commented Nov 26, 2024

#821

⚡ Summary

Git LFS is an opt-in feature that lets people store large files outside a git repository, saving only pointers to them in the git repository itself.

Git does not use LFS by default. One must manually specify files and file patterns using the .gitattributes file.

I've found that LFS adds about 2.2 seconds when running lefthook in my employer's large git repo.

My small benchmark
❯ /usr/bin/time git lfs post-checkout e6f8d32b e6f8d32b 0
        2.24 real         0.39 user         1.51 sys
❯ /usr/bin/time git lfs post-checkout e6f8d32b e6f8d32b 0
        2.22 real         0.39 user         1.50 sys
❯ /usr/bin/time git lfs post-checkout e6f8d32b e6f8d32b 0
        2.28 real         0.41 user         1.51 sys
❯ /usr/bin/time git lfs post-checkout e6f8d32b e6f8d32b 0
        2.29 real         0.41 user         1.51 sys
❯ /usr/bin/time git lfs post-checkout e6f8d32b e6f8d32b 0
        2.30 real         0.42 user         1.53 sys

Considering the ~500 engineers in my company, and assuming an average of 1 git checkout per day (I assume this is a low estimate, but I don't have metrics on this), we'd save 6.1 hours of engineering time every month.

NOTE

I'd personally recommend that we rework this feature—that we change the flag to enable_lfs and disable LFS hooks by default. I'm more than happy to do so.

Because LFS is fully opt-in, and because of its poor performance in large repositories, I don't believe it makes sense to enable this feature by default.

ALSO NOTE

I disabled LFS for this project as well since it's not needed here (see "chore" commit). I assume you will want me to revert that change! I'm more than happy to 😅.

☑️ Checklist

  • Check locally
  • Add tests
  • Add documentation

Copy link
Member

@mrexox mrexox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thank you for this PR! I like this change, but I have a concern on naming. Could you call it "skip lfs" everywhere (config, arg, run option)?

As of this commit, this repository does not use git LFS.

You can verify this through two ways:

1. By running `git lfs ls-files` and seeing which files are using LFS.
2. By checking the `.gitattributes` file in this repo to see if LFS
   is enabled on any files.
@zachahn
Copy link
Contributor Author

zachahn commented Nov 27, 2024

Done! I added a simple test too, but it doesn't really test anything besides going through the new code path. Let me know if you'd like any other changes.

Just to confirm, I'm guessing you might not want to flip the default and disable LFS unless explicitly enabled? I would love to bring this improvement to all repositories that use lefthook, but I understand that could be classified as a breaking change. But of course, I'm happy with this PR as is :)

Thanks for reviewing!

@mrexox mrexox merged commit 2c874a9 into evilmartians:master Nov 28, 2024
16 of 19 checks passed
@zachahn zachahn deleted the config-skip-lfs branch November 29, 2024 15:48
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 this pull request may close these issues.

3 participants