You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
git-lfs is unusable slow (especially on Windows) #376
git-lfs for every file establish new ssh connection and executes git-lfs-authenticate command (aditional ~0.3 sec per file on Windows, ~0.2 sec per file on Linux);
git-lfs for every file executed as separate process (additional ~0.2 sec per file on Windows);
It should be noted that in the case of:
if the git-lfs-authenticate knows how files are stored, then he could immediately return the "download" section and save one HTTP request;
if the git-lfs-authenticate don't knows how files are stored, it always returns the same result.
In addition, processing each file in a separate process does not allow reusing HTTP connections.
Working copy contains 4231 LFS files (total size: 3.6G).
All data hosted in local gigabit network. I am sure that in the case of slower network results will be much sadder.
Versions:
Windows test:
Windows 8.1
git-lfs: 0.5.1
git: 1.9.5.msysgit.1
ssh: OpenSSH_6.6p1, OpenSSL 1.0.1f 6 Jan 2014
Linux test
Ubuntu 14.04.2 LTS
git-lfs: 0.5.1
git: 1.9.1
ssh: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
Hey @bozaro, thanks for the feedback. There are several causes of pain here:
As you mentioned, the smudge filter downloads files one at a time in a separate process. This is how Git works, so the only thing we can do is to not use it ;) The master branch already has an early version of a git lfs fetch command that can download objects in parallel. We plan to investigate using a post-checkout hook to download the files with the new fetch command.
The core Git LFS API is very chatty, requiring an HTTP call for every upload or download. The master branch already has support for an experimental batch API. This is coupled with the work on the new fetch command.
We also plan to investigate reducing the number of SSH calls by some in-memory caching made possible by a single fetch command, as opposed to multiple smudge filter calls.
I build git-lfs 0.5.1 with changes: #380 + #377
After I setup git to use plink with "Share SSH connections if possible" and clone time reduced on Windows to 3561.472 sec.
It's 1.40X time faster then original time.
At the moment, we have put in git-lfs only a few particularly large files (~80 lfs files in the working copy).
This half-measure will significantly reduce the size of the repository. But git clone (repository ~8Gb) takes longer than git lfs. Full clone with lfs data now takes 15-20 minutes.
We would like to use git-lfs for ~5000 working copy files. But with smudge filter it does not look real.
Using git lfs pull requires the support of our build farm. We have not done it since I was not aware of the environment variable GIT_LFS_SKIP_SMUDGE.
Ah ok. I think GIT_LFS_SKIP_SMUDGE is only in the current git version?
You can also do "git clone -n", then do "git lfs fetch origin ", and "git checkout ". I believe this should be similar to using GIT_LFS_SKIP_SMUDGE git clone + git lfs fetch.
All of this assumes you have batch enabled.
We're very new to using git, and we're moving a big project with a large number of big libs into a github private repo. We're setting up submodules with git-lfs for several projects that have 2.2GB of third-party libs. We've named the submodule "big_libs".
We had exactly the problem described in this thread, and the previous comment helped us a ton for the main repo. Now, I need to do the same thing for the submodule "big_libs".
I want a series of operations that I can run to make: git clone --recursive <repo>
If you use GIT_LFS_SKIP_SMUDGE=1 in your environment, that should prevent one-at-a-time smudge from happening. Only problem is, I'm not sure GIT_LFS_SKIP_SMUDGE exists in git-lfs 1.0 yet. You may need to build the latest git-lfs from the git repo to get that feature. Maybe one of the devs can chime in to answer definitively though.
While the GIT_LFS_SKIP_SMUDGE-workaround works great for me since I'm using git from the command line on Linux, it doesn't help my colleagues who use GitHub Desktop on Windows. We have 16354 audio files in git lfs and each one of them takes two or three seconds to retrieve using GitHub Desktop, so it's going to take a whole day (22 hours if we assume 5 seconds per audio file!) to make the initial clone of our repo.
GitHub Desktop on Windows bundles git-lfs and provides a "Git Shell" shortcut that loads the proper environment. This lets them access git-lfs from the command line to run custom commands without having to manually install git-lfs separately.
FYI, for anyone looking for a sane workaround for an extremely slow git clone (and who doesn't want to read through all these issues), try this:
set GIT_LFS_SKIP_SMUDGE=1
git clone http://whatever.git
cd Whatever
git lfs pull
Note: set GIT_LFS_SKIP_SMUDGE=1 is how you set an environment variable in the Windows command line. Your shell may be different.
Explanation-in-a-nutshell: git-lfs magically integrates with normal git commands (clone, pull, push, etc) through a git feature called filters. The filters are the bottleneck (they force git-lfs to download each file in serial, plus some other slowness). When you want to download files from the server (e.g. git fetch), the "smudge" filter runs. By setting the GIT_LFS_SKIP_SMUDGE environment variable, you tell git-lfs to skip trying to download files as part of the standard git commands. That frees you to run git lfs pull separately, which by default downloads files in batches of 3 (you can increase this number, but I've found that's fast enough for me). It is way faster.
Until you either close your command prompt or unset the GIT_LFS_SKIP_SMUDGE variable, this will continue to be the case. Since git clone is guaranteed to be slow (we have to download every file), it makes sense to always do the git lfs pull separately, but for everyday git pull and git push operations, remembering to run the corresponding git-lfs command can be annoying, so we let it work magically by leaving the GIT_LFS_SKIP_SMUDGE variable unset most of the time. You can of course turn it on and off at your leisure.
From git-lfs 1.2 (or master right now) you can use git lfs clone to speed up clones even more than using GIT_LFS_SKIP_SMUDGE. I'm proposing we add similar options for checkout & pull in future.
Discussed in more detail in #931 but basically avoiding calling the filter executable at all makes it faster than calling it and then doing nothing like GIT_LFS_SKIP_SMUDGE does, especially on Windows.
@R-ku The reason is down to how git tries to detect file changes. An in-depth discussion is here: https://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt but it boils down to the fact that because of timer precision and fast machines, a simple check of date/time stamps isn't always good enough and when a file goes through a filter like git-lfs does, git can only compare to the index by putting the current contents of the file through the clean filter. In bulk, this can cause an issue sometimes; it's actually worse on files you haven't modified yourself, because when you modify yourself there's often a time delay between the last edit you make, and the time you add/commit. It's worse on clean clones on a fast machine because of the likelihood that a lot of the timestamps will be the same.
The only workaround I know right now is a bit nasty, and I'd only recommend using it once it's a significant problem for you. You can disable git's checking of files by doing this:
git update-index --assume-unchanged <path>
Once you do that though, git status will not show changes in those paths; you can still add things to the index in those paths but it won't show up as modified just by saving the file. You can undo this setting with the same command just with --no-assume-unchanged. It's not a great solution but if it's hurting you badly, it's a coping mechanism. Most filter-based systems hit this problem and I haven't so far found a comprehensive solution.
@R-ku Ah yup, I wrote a terrible description of that command :) However, Git's clean filter doesn't overwrite files in your working directory. It reads the file contents through a command before checking for a change and/or writing it to git's object database. The Git LFS clean filter reads the data and outputs the LFS text pointer instead.
Would it essentially delete all that 12GB of files one by one and place it back just for checking if file did not change?
No, it just reads the files and converts to a pointer (piped to stdout) which is compared against the index. It doesn't even need to write that converted pointer anywhere on the disk, the comparison can be done by reading the index in parallel (in blocks) and matching. So it's only disk reads, no writes.
Update: I tried this again (2015) and it seems that git status and git add avoid re-sending the file content to the clean filter, as long as the file stat has not changed. I'm not sure when git started doing that, but it seems to avoid this problem. --Joey
This is my experience and GIT_TRACE shows that the clean filter on status is avoided in many cases for me. But the rest of those threads are basically what I was talking about - when the clean filter IS called, either because the time stamps are too close (and this is not 'wrong', it's just a feature of fast file systems and clock precision) the scalability issue is a known, so far unsolved problem, by any of us. git update-index --assume-unchanged is the only workaround I know of right now besides going completely outside git filters and doing it manually, which substantially increases the complexity for the user and hence chance of mistakes.
Activity
bozaro commentedon Jun 10, 2015
Also performance on Windows can be improvement by changing in
.gitconfig:From:
To:
This small change reduce clone time on Windows from 4970 sec to 4352 sec (1.14X faster).
bozaro commentedon Jun 10, 2015
I try to use ssh multiplexing as workaround (http://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing).
It's reduce clone time on Linux from 1436 sec to 541 sec (2.65X faster).
But I could not get this feature to work under Windows.
technoweenie commentedon Jun 10, 2015
Hey @bozaro, thanks for the feedback. There are several causes of pain here:
As you mentioned, the smudge filter downloads files one at a time in a separate process. This is how Git works, so the only thing we can do is to not use it ;) The master branch already has an early version of a
git lfs fetchcommand that can download objects in parallel. We plan to investigate using apost-checkouthook to download the files with the new fetch command.The core Git LFS API is very chatty, requiring an HTTP call for every upload or download. The master branch already has support for an experimental batch API. This is coupled with the work on the new fetch command.
We also plan to investigate reducing the number of SSH calls by some in-memory caching made possible by a single fetch command, as opposed to multiple smudge filter calls.
Also, thanks for #377 :)
bozaro commentedon Jun 11, 2015
I got ssh multiplexing to work under Windows :)
I build git-lfs 0.5.1 with changes: #380 + #377
After I setup git to use plink with "Share SSH connections if possible" and clone time reduced on Windows to 3561.472 sec.
It's 1.40X time faster then original time.
AndrewJDR commentedon Oct 6, 2015
bonzaro, thanks for your notes.
I'm curious... how long does the following take with your repo (and with batch enabled in your .gitconfig)
enable batch in ~/.gitconifg first:
bozaro commentedon Oct 6, 2015
At the moment, we have put in git-lfs only a few particularly large files (~80 lfs files in the working copy).
This half-measure will significantly reduce the size of the repository. But git clone (repository ~8Gb) takes longer than git lfs. Full clone with lfs data now takes 15-20 minutes.
We would like to use git-lfs for ~5000 working copy files. But with smudge filter it does not look real.
Using git lfs pull requires the support of our build farm. We have not done it since I was not aware of the environment variable GIT_LFS_SKIP_SMUDGE.
AndrewJDR commentedon Oct 6, 2015
Ah ok. I think GIT_LFS_SKIP_SMUDGE is only in the current git version?
You can also do "git clone -n", then do "git lfs fetch origin ", and "git checkout ". I believe this should be similar to using GIT_LFS_SKIP_SMUDGE git clone + git lfs fetch.
All of this assumes you have batch enabled.
golsby commentedon Oct 12, 2015
We're very new to using git, and we're moving a big project with a large number of big libs into a github private repo. We're setting up submodules with git-lfs for several projects that have 2.2GB of third-party libs. We've named the submodule "big_libs".
We had exactly the problem described in this thread, and the previous comment helped us a ton for the main repo. Now, I need to do the same thing for the submodule "big_libs".
I want a series of operations that I can run to make:
git clone --recursive <repo>Fast like:
I tried:
but the last line gets us back into the one-file-at-a-time git lfs downloads.
Can I just do:
And have the submodule be properly cloned by git for future
git submodule updatecalls?AndrewJDR commentedon Oct 13, 2015
If you use GIT_LFS_SKIP_SMUDGE=1 in your environment, that should prevent one-at-a-time smudge from happening. Only problem is, I'm not sure GIT_LFS_SKIP_SMUDGE exists in git-lfs 1.0 yet. You may need to build the latest git-lfs from the git repo to get that feature. Maybe one of the devs can chime in to answer definitively though.
AndrewJDR commentedon Oct 13, 2015
You might also try something like
The foreach command should run the lfs fetch in each submodule. If you do that prior to submodule update then you should be all set.
josteinaj commentedon Dec 14, 2015
While the
GIT_LFS_SKIP_SMUDGE-workaround works great for me since I'm using git from the command line on Linux, it doesn't help my colleagues who use GitHub Desktop on Windows. We have 16354 audio files in git lfs and each one of them takes two or three seconds to retrieve using GitHub Desktop, so it's going to take a whole day (22 hours if we assume 5 seconds per audio file!) to make the initial clone of our repo.technoweenie commentedon Dec 14, 2015
@josteinaj You can work around it for now by cloning from GitHub Desktop's shell manually.
WestonThayer commentedon Jan 28, 2016
@technoweenie could you elaborate on that? You have to use the GitHub Desktop GUI?
technoweenie commentedon Feb 1, 2016
GitHub Desktop on Windows bundles git-lfs and provides a "Git Shell" shortcut that loads the proper environment. This lets them access git-lfs from the command line to run custom commands without having to manually install git-lfs separately.
slonopotamus commentedon Feb 2, 2016
The only sane solution for this bug is to add batch smudge filter support to Git itself. All the rest is doomed to be half-crippled workarounds.
AndrewJDR commentedon Feb 2, 2016
+1 @slonopotamus
WestonThayer commentedon Feb 23, 2016
FYI, for anyone looking for a sane workaround for an extremely slow
git clone(and who doesn't want to read through all these issues), try this:Explanation-in-a-nutshell: git-lfs magically integrates with normal git commands (
clone,pull,push, etc) through a git feature called filters. The filters are the bottleneck (they force git-lfs to download each file in serial, plus some other slowness). When you want to download files from the server (e.g.git fetch), the "smudge" filter runs. By setting theGIT_LFS_SKIP_SMUDGEenvironment variable, you tell git-lfs to skip trying to download files as part of the standard git commands. That frees you to rungit lfs pullseparately, which by default downloads files in batches of 3 (you can increase this number, but I've found that's fast enough for me). It is way faster.Until you either close your command prompt or unset the
GIT_LFS_SKIP_SMUDGEvariable, this will continue to be the case. Sincegit cloneis guaranteed to be slow (we have to download every file), it makes sense to always do thegit lfs pullseparately, but for everydaygit pullandgit pushoperations, remembering to run the corresponding git-lfs command can be annoying, so we let it work magically by leaving theGIT_LFS_SKIP_SMUDGEvariable unset most of the time. You can of course turn it on and off at your leisure.sinbad commentedon Feb 24, 2016
From git-lfs 1.2 (or master right now) you can use
git lfs cloneto speed up clones even more than usingGIT_LFS_SKIP_SMUDGE. I'm proposing we add similar options for checkout & pull in future.AndrewJDR commentedon Feb 24, 2016
@sinbad - Curious, what makes git lfs clone faster than skipping smudge followed by a subsequent git lfs pull?
sinbad commentedon Feb 24, 2016
Discussed in more detail in #931 but basically avoiding calling the filter executable at all makes it faster than calling it and then doing nothing like
GIT_LFS_SKIP_SMUDGEdoes, especially on Windows.sinbad commentedon Feb 29, 2016
@R-ku The reason is down to how git tries to detect file changes. An in-depth discussion is here: https://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt but it boils down to the fact that because of timer precision and fast machines, a simple check of date/time stamps isn't always good enough and when a file goes through a filter like git-lfs does, git can only compare to the index by putting the current contents of the file through the clean filter. In bulk, this can cause an issue sometimes; it's actually worse on files you haven't modified yourself, because when you modify yourself there's often a time delay between the last edit you make, and the time you add/commit. It's worse on clean clones on a fast machine because of the likelihood that a lot of the timestamps will be the same.
The only workaround I know right now is a bit nasty, and I'd only recommend using it once it's a significant problem for you. You can disable git's checking of files by doing this:
Once you do that though,
git statuswill not show changes in those paths; you can still add things to the index in those paths but it won't show up as modified just by saving the file. You can undo this setting with the same command just with--no-assume-unchanged. It's not a great solution but if it's hurting you badly, it's a coping mechanism. Most filter-based systems hit this problem and I haven't so far found a comprehensive solution.technoweenie commentedon Feb 29, 2016
@R-ku Ah yup, I wrote a terrible description of that command :) However, Git's clean filter doesn't overwrite files in your working directory. It reads the file contents through a command before checking for a change and/or writing it to git's object database. The Git LFS clean filter reads the data and outputs the LFS text pointer instead.
sinbad commentedon Feb 29, 2016
No, it just reads the files and converts to a pointer (piped to stdout) which is compared against the index. It doesn't even need to write that converted pointer anywhere on the disk, the comparison can be done by reading the index in parallel (in blocks) and matching. So it's only disk reads, no writes.
sinbad commentedon Mar 1, 2016
From your first link:
This is my experience and GIT_TRACE shows that the clean filter on status is avoided in many cases for me. But the rest of those threads are basically what I was talking about - when the clean filter IS called, either because the time stamps are too close (and this is not 'wrong', it's just a feature of fast file systems and clock precision) the scalability issue is a known, so far unsolved problem, by any of us.
git update-index --assume-unchangedis the only workaround I know of right now besides going completely outside git filters and doing it manually, which substantially increases the complexity for the user and hence chance of mistakes.