Skip to content

'delay' filter-process capability #2466

Closed

Description

@ttaylorr

Goal

Improve the speed at which Git LFS performs checkouts with a majority of
uncached objects.

Background

Late last year, we added support for the new process filter, added in Git
v2.11.0, as a means to convert files during check-in/out operations. This
greatly improved the performance of both operations, most notably on Windows,
where the overhead of spawning git-lfs-clean(1) or git-lfs-smudge(1) for
each file in the operation incurred significant overhead. (See:
#1329 (comment)).

We noted, however, that this protocol (as is the case with 'smudge' and 'clean'
filters) has an opportunity to improve its performance with uncached items.
Consider the following:

  1. Git does a checkout operation after a fetch or clone on a repository with
    many LFS objects.
  2. Git asks LFS for the first remaining object in the checkout.
  3. LFS sees that the object is not in the cache, since this is a clone and no
    objects are cached yet.
  4. LFS downloads the file in whole, and then responds to Git.
  5. If the checkout is done, see step 6, else see step 2.
  6. Done

In the above, LFS has to download each large file one at a time before it can
move onto the next. While thinking about ways to improve this, I summarized some
discussion that @larsxschneider and I had been having in
#1632 (comment):

@larsxschneider and I have already begun talking about adding a new capability
to the protocol to allow the git-filter-server (LFS) to "promise" that it
will convert a file and yield the path on disk where it will dump the result
of that conversion. [...]

This will allow us to process many transfers concurrently, taking full
advantage of the proposed new transfer queue design, and yielding even greater
speeds for the new filter protocol implementation. Perhaps more importantly,
it will allow us to do normal Git operations (git clone, git push,
git pull, and etc.) without needing to temporarily disable the smudge filter
to parallelize the transfers. [...]

Propositions

Lars has already implemented a spike of what support for what this would look
like in #1646.

Since Lars' patch (see: git/git@487fe1f) is on 'next' and 'pu', I propose that we
expand on his spike above and add support for the 'delay' capability into Git LFS.

Technical Overview

See: the documentation in gitattributes.txt.

Non-goals

While this would allow us to remove two helper commands:

  • git lfs clone
  • git lfs fetch

I don't think that we can do this until a MAJOR semantic version, the next of
which would be v3.0.0. At that time, or before, I'd like to discuss the
feasibility of removing these commands.


/cc @git-lfs/core
/cc @larsxschneider

Activity

  1. added this to the v2.3.0 milestone on Aug 2, 2017
  2. larsxschneider commented on Aug 2, 2017

    @larsxschneider
    Member

    Sounds all good. However, I don't think we can get rid of git lfs fetch because git fetch would never filter any files and therefore no Git LFS process would be invoked. git lfs clone could certainly go 😄 ! Maybe we can mark it as deprecated with a warning on invocation in the 2.x series already?

  3. ttaylorr commented on Aug 2, 2017

    @ttaylorr
    ContributorAuthor

    However, I don't think we can get rid of git lfs fetch because git fetch would never filter any files and therefore no Git LFS process would be invoked.

    Ah, of course! git lfs fetch will have to stay. It would be nice if git fetch could accept arbitrary flags that would be forwarded to any filter(s), but maybe that's for another time...

    Maybe we can mark it as deprecated with a warning on invocation in the 2.x series already?

    Great idea: I think we should definitely do this.

  4. larsxschneider commented on Aug 14, 2017

    @larsxschneider
    Member

    The "delay" filter would also speed up the following use cases:

    (1) If you switch to a branch (git checkout xyz) with a lot of LFS files that you don't have on your local machine, yet.

    (2) If you rebase onto a branch (git rebase) that has a lot of LFS that you don't have on your machine, yet.

    (3) If you pull from a branch (git pull) to which other people added a lot of LFS files since you pulled last.

    In all these use cases "pre-delay Git LFS" would download the LFS files sequentially. With the delay filter Git LFS can download the files in parallel. With "a lot of LFS files" I mean more than 20 or so.

    On top of all that Git LFS will become faster in all kinds of tools that shell out to Git (Jenkins, SmartGit, SourceTree, ...). For instance Jenkins doesn't know about special commands such as git lfs clone. Therefore, git clone is horrible slow for repositories with many files in LFS. The delay filter will make all these tools immediately faster.

    --

    🎉 The delay filter was just merged into the master branch of git/git 🎉

  5. technoweenie commented on Aug 14, 2017

    @technoweenie
    Contributor

    git lfs clone could certainly go 😄 ! Maybe we can mark it as deprecated with a warning on invocation in the 2.x series already?

    I'm all for deprecating it. We should recommend users update Git, but keep the command around for any stragglers. Also, reject PRs for support of any new clone flags, since new flags would mean you have a new enough Git with delay support :) 👍

  6. larsxschneider commented on Oct 30, 2017

    @larsxschneider
    Member

    Git 2.15 shipped with support for delayed filters today 🎉
    https://public-inbox.org/git/[email protected]/

    Hidden in the release notes as:

    • The filter-process interface learned to allow a process with long
      latency give a "delayed" response.
  7. jamesblackburn commented on Nov 14, 2017

    @jamesblackburn

    In case this helps someone googling. I updated an existing environment to git=2.15.0 and git-lfs=2.3.4 and still saw no delayed functionality... git lfs clone was still significantly faster and warning:

    WARNING: 'git lfs clone' is deprecated and will not be updated
              with new flags from 'git clone'
    
    'git clone' has been updated in upstream Git to have comparable
    speeds to 'git lfs clone'.
    

    Turned out the fix is to run install at least once more:

    git lfs install
    

    at least once with the new versions of git and git-lfs.

  8. larsxschneider commented on Nov 14, 2017

    @larsxschneider
    Member

    Interesting. I guess the reason was that your global Git config did not include filter.lfs.process, yet.

    @ttaylorr / @technoweenie : Is that possible? I thought Git LFS would update the global Git config in that case but I am not familiar with these code paths...

  9. technoweenie commented on Nov 14, 2017

    @technoweenie
    Contributor

    Sure, Git LFS can do that with git lfs install or git lfs update (either will work). The trick is actually running it. It is run automatically if you install through our windows installer, debian package, rpm, or the install.sh included in our the prebuilt tarballs. I'm not sure about other GUIs like GH Desktop or SourceTree, so you'll have to check with them. If you're compiling on your own, well you're on your own :)

  10. larsxschneider commented on Nov 15, 2017

    @larsxschneider
    Member

    @jamesblackburn How did you get LFS 2.3.4 on your machine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions