Live data from Hacker News

My experience with using cp to copy 432 million files (39 TB)

lists.gnu.org

51–60 of 267 posts

Re: My experience with using cp to copy 432 million files (39 TB)

#51
post #21
post #5

I wonder how well rsync would have fared here.

Rsync can die just from scanning the whole directory tree of files first.

The incremental option(enabled by default) introduced in rsync 3.0 greatly reduces the need for scanning the whole directory structure.

Re: My experience with using cp to copy 432 million files (39 TB)

#52

This may be a little off topic, but I used to think RAID 5 and RAID 6 were the best RAID configs to use. It seemed to offer the best bang for buck. However, after seeing how long it took to rebuild an array after a drive failed (over 3 days), I'm much more hesitant to use those RAIDS. I much rather prefer RAID 1+0 even though the overall cost is nearly double that of RAID 5. It's much faster, and there is no rebuild…

How does the rebuild time of ZFS's raidz compare to RAID5/6?

It really depends on the load and if your raidz has 1,2, or 3 spare drives. From what I've experienced, re-slivering a the new drive in a raidz seems to happen at about 30% of the maximum ZFS throughput under medium load. And even better than many RAID5/6 implementations - it only re-slivers enough to store your data and not just the entire drive.

Re: My experience with using cp to copy 432 million files (39 TB)

#53
post #27

Unix could really use a way to get all the paths that point to a given inode. These days that shouldn't really cost all that much and this issue comes up a lot in copying/sync situations. Here's the git-annex bug report about this: https://git-annex.branchable.com/bugs/Hard_links_not_synced_...

Seems like this is actually a feature in VxFS:

https://sort.symantec.com/public/documents/sfha/6.0/linux/pr... http://sfdoccentral.symantec.com/sf/5.0/aix/manpages/vxfs/vx...

I wonder if any modern filesystems (xfs/ext4/btrfs/zfs) can actually enable tracking this.

Re: My experience with using cp to copy 432 million files (39 TB)

#54
post #34

Earlier quoted context omitted.

Looking at the code, it looks like deallocating a hash table requires traversing the entire table, because there is malloc()'d memory associated with each hash entry, so each entry has to be visited and free()'d. From hash_free() in coreutils hash.c: for (bucket = table->bucket; bucket bucket_limit; bucket++) { for (cursor = bucket->next; cursor; cursor = next) { next = cursor->next; free (cursor); } } Whereas if you…

Why exactly is it necessary to to free each hash entry instead of exiting the process?

It's not necessary per se, but many programmers do it out of good habits. It becomes much harder to e.g. find memory leaks in your code if you never free the memory you haven't leaked. And normally the extra overhead it entails is imperceptible.

Obviously many programmers do not think to (or cannot easily) test their code with 40 TBs of data.

Re: My experience with using cp to copy 432 million files (39 TB)

#55
post #10

Interesting. In Windows-land, the default copy is pretty anemic, so probably most people avoid it for serious work. I'd probably use robocopy from the command line. And if I was being lazy, I'd use the Teracopy GUI. I think my limit for a single copy command has been around 4TB with robocopy--and that was a bunch of large media files, instead of smaller more numerous files. Maybe there's a limit I haven't hit.

When I was using Windows, I personally used Robocopy to make to personal backups to external drives. I was happy when MS started including it in Windows.

Re: My experience with using cp to copy 432 million files (39 TB)

#57

So it was all the files in one go, presumably with `cp -r`? What about doing something with find/xargs/i-dunno to copy all the files, but break em into batches so you aren't asking cp to do it's bookkeeping for so many files in one process? Would that work better? Or worse in other ways?

The idea that you would need to do this seems fundamentally broken to me.

Re: My experience with using cp to copy 432 million files (39 TB)

#58
post #29

Earlier quoted context omitted.

You're right to recommend a tarpipe. I've had to copy several very large BackupPC storage pools in the past, and a tarpipe is the most reliable way to do it. (The only downside to BackupPC IMO...) For future reference for other folks, the command would look something like this: cd /old-directory && tar czvflpS - . | tar -C /new-directory -xzvf - Tarpipes are especially neat because they can work well over ssh (make s…

What's the benefit of using a tarpipe locally?

No giant bookkeeping datastructures that end up with the process thrashing in swap, because tar is designed to work with so many files that you don't want to keep the metadata in memory.

Re: My experience with using cp to copy 432 million files (39 TB)

#59

So it was all the files in one go, presumably with `cp -r`? What about doing something with find/xargs/i-dunno to copy all the files, but break em into batches so you aren't asking cp to do it's bookkeeping for so many files in one process? Would that work better? Or worse in other ways?

It should work much better provided you can easily divide it into batches where you know they don't have any shared hardlinked files. Otherwise you will duplicate those files wasting some space. That may be fine as well though.

Re: My experience with using cp to copy 432 million files (39 TB)

#60
post #23
post #2

I would probably have used tar|tar for this, or rsync.

I'm unfamiliar with tar|tar, can you provide some incite into this trick?

Not much of a trick, the first tar serializes the entire directory structure including all the metadata into a stream of bytes, from which the second tar reassembles it.

Basically the same as tar's standard usage, except you don't store that stream as a tar file/image anywhere.

Post reply on HN