Reflink shared/copy subtrees in a single syscall#22
Merged
Conversation
ApplyCopy previously walked every file under shared/copy/ and reflinked each one individually — ~4 syscalls per file, so a Composer vendor/ with 20k files took ~4s of pure syscall overhead after "copied vendor/" printed. APFS clonefile(2) accepts directories and clones the whole hierarchy in one syscall, so fast-path each template-free top-level subtree via a new fscopy.CopyTree and fall through to the existing per-file walk for top-level files, template-containing subtrees, pre-existing destinations, and non-APFS/Linux volumes. Measured 6.2s → 2.0s wall-clock for `wt add --skip-setup` in a 20,762-file project; system CPU drops 4.94s → 0.98s.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ApplyCopynow tries a singleclonefile(2)per template-free top-level directory inshared/copy/via a newfscopy.CopyTree, collapsing the ~20k per-file reflinks for a Composer vendor/ into one syscall.WalkDir+CopyFilepath for top-level files, subtrees containing.templatefiles, destinations that already exist, and any filesystem/platform that returnserrReflinkUnsupported(Linux FICLONE is file-only and stays on the per-file path).wt add --skip-setupin a 20,762-file project: 6.18s → 2.04s wall-clock, 4.94s → 0.98s system CPU.Test plan
make dev(fmt + vet + test + build)GOOS=linux go build ./...cross-compileTestCopyTreeNested,TestCopyTreePreservesSymlink,TestCopyTreeExistingDst,TestIsReflinkUnsupportedin fscopy;TestApplyCopyFastPathForDirectories,TestApplyCopyFallsBackWhenTreeContainsTemplate,TestApplyCopyFastPathPreservedWhenVarsNilin project~/Sites/affiliatedwith--skip-setup— pause aftercopied vendor/is gone