graphdriver/copy: faster copy of hard links#46812
Conversation
The DirCopy() function in "graphdriver/copy/copy.go" has a special case for skip file-attribute copying when making a hard link to an already-copied file, if "copyMode == Hardlink". Do the same for copies of hard-links in the source filesystem. Significantly speeds up vfs's copy of a BusyBox filesystem (which consists mainly of hard links to a single binary), making moby's integration tests run more quickly and more reliably in a dev container. Fixes moby#46810 Signed-off-by: Rob Murray <rob.murray@docker.com>
|
Some failure on Windows; looks like it already was restarted once (but haven't checked if it was the same failure); let me post it here in case it's related; |
|
Looks like that was a glitch; CI is happy now 👍 |
|
Out of curiousity; had a quick check why this was missing; The Looking at this code, I'm now actually wondering if we should have that variable at all, or if we instead could just return early (which is what the |
Minimal change seemed like the best plan for my first commit (!) ... but factoring the "switch" out into a function that returns something to say whether to copy the metadata would make the intention hard to miss. (There might also be scope for speeding up regular-file copying by doing some of the i/o bound work in parallel on a pool of worker goroutines. But, speeding up the BusyBox-based integration tests seemed like a quick-win worth having, and I wasn't sure whether there was any driver to try to go further.) |
Fixes #46810
Speed up vfs's copy of a BusyBox filesystem (which consists mainly of hard links to a single binary), making moby's integration tests run more quickly and more reliably in a dev container.
The DirCopy() function in "graphdriver/copy/copy.go" has a special case for skip file-attribute copying when making a hard link to an already-copied file, if "copyMode == Hardlink". Do the same for copies of hard-links in the source filesystem.
Running the integration tests, as described in #46810 ...
Without the change (and with the printfs described above), in this case all the tests finished just within their 5s timeouts in ~88s:
With the change, tests completed in ~22s:
Unit tests are still happy...
graphdriver/copy: faster copy of hard links