Skip to content

Use clonefile system call on Mac OS X for faster & efficient object file copy #3740

Closed

Description

@kazuki-ma

Mac OS X implements "copy on write" file copy mechanism since OS X version 10.12.
That called clonefile. https://www.manpagez.com/man/2/clonefile/

If we use it. Copy from object store to working tree don't need additional space.
Of course, user can modify working tree files without any concern, it makes clonefile differ from symlink/hardlink.

Activity

  1. bk2204 commented on Jul 29, 2019

    @bk2204
    Member

    Hey,

    Thanks for writing in. I agree this would be a nice change to have, but I'm not sure it's possible to achieve, and here's why.

    Git LFS doesn't actually write files to the disk itself unless you use git lfs checkout manually. Normally, Git runs a smudge or clean filter, and invokes Git LFS through a piped context. As a result, Git LFS doesn't get the opportunity to decide how to write files; Git does that instead. Because the smudge and clean mechanism isn't intended for what Git LFS is using it for, I'm not sure if upstream would be willing to accept a patch to change things.

    I'll leave this open as a possibility of a new feature that could be implemented and mark it as an enhancement.

  2. kazuki-ma commented on Jul 29, 2019

    @kazuki-ma
    ContributorAuthor

    Aha, you are right.

    I just noticed we cant touch actual file in woking tree during filter process. Thank you.

    But I have another idea.

    Creating new sub commamd like git lfs dedup(de-duplication) is possible. New command process lfs-nized file in working tree, delete each files and replace it with cloned one from lfs storage.

    This is not ideal solution but saves disk usage also.

  3. bk2204 commented on Jul 29, 2019

    @bk2204
    Member

    Hey,

    I think such a feature is interesting, but it wouldn't work on all platforms, since most of the platforms we support don't have copy-on-write features, and we can't use hardlinks. I'm not opposed to seeing a pull request that implements support for this, provided we do something sane on file systems where it isn't supported.

  4. kazuki-ma commented on Jul 30, 2019

    @kazuki-ma
    ContributorAuthor

    Thank you for your feedback.
    Let's me try thinking and creating PR. I try to support XFS and Btrfs users also.

    Background:

    Where are many asset-heavy repository in game development. (As you know)
    Typical working tree size is over 100GiB and we have to checkout 10~100 times on CI environment.
    (per branch x per job name)

    And each developers have local 2~5 checkout in their local environment.

    If we can de-dup those working-tree files and object file into one, it is not difficult when case of git new-workdir is used or lfs.storage is set, I think users very happy.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions