by idoubtit · 5y ago · 0 comments
But the main problem is not the suspicious performance, it's the lack of explanation. The tool is supposed to "find duplicate files (photos, videos, music, documents)". Does it mean it is restricted to some file types? Does it find identical photos with different metadata to be duplicates? Compare this with rdfind which clearly describes what it does, provides a summary of its algorithm, and even mentions alternatives.
Overall, it may be a fine toy/hobby project (3 commits only, 3 months ago), I didn't read the code (except for finding the command-line options). I don't get why it got so much attention.
fdupes is the classic (going way way back) but it's really very slow, not worth using anymore.
The four I know are worth trying these days (depending on data set, hardware, file arrangement and other factors, any one of these might be fastest for a specific use case) are:
https://github.com/jbruchon/jdupes
https://github.com/pauldreik/rdfind
https://github.com/jvirkki/dupd
https://github.com/sahib/rmlint
Had not encountered fclones before, will give it a try.
The efficient way to do things is to just read files in parallel and break once they diverge. Basically how `cmp` works.
Example. For fileX.txt being X=1 to 10000 you have three copies of each archive in:
mydir/file-X.txt
mydir/subdir/file-X.txt and
mydir/subdir/copy/file-X.txt.
Fdupes would delete random files in mydir/, mydir/subdir/ and mydir/subdir/copy/. You would end with the remaining files scattered by all the directory tree. A mess with three incomplete copies.
Rdfind correctly guess that what most people would want is to remove entirely all files in two of the directories and keep one copy (files and tree-dir) intact. So it wipes the inner subdirs in a predictable way and keeps the outer dir intact. This is a terrific feature able to disentangle one tree directory cloned and nested into the original copy without distroying it, like in this case:
a/b/c/d/files00X.txt
a/b/a/b/c/d/files00X.txt
Computing incremental checksums in parallel and breaking up once checksums diverge does not work very well on HDDs because the files can be in distant physical locations, and that would cause lot of seeks (seeks are terribly slow on rotational drives).
That's going to be pretty slow on a hard disk because it scatters the reads causing a lot of head movement.
If all equally-sized files on your disk are duplicates, it makes you read both files in their entirety in a scatter version. That’s (expected to be) slow, indeed.
However, if most of them aren’t, chances are you find a difference in the first block read, which means you have to read only two blocks to decide they’re different.
So, what’s that distribution? Also, where is one most likely to find differences in equally-sized files? First block? Last?
It initially groups files that have the "same extension and same size", so you're out of luck if you have two copies named foo.jpg and foo.jpeg.
Then, it cheats by computing a crc32 (!) of the beginning, middle, and end bytes of the file and groups together files that have the same crc32.
So, it'll mostly work, but miss a lot of duplicates, and potentially flag different files as duplicates.
The cynical side of me wants to know what features and safety checks a "blazingly fast" tool has not implemented that the older "glacially slow" tool it is replacing ended up implementing after all the edge conditions were uncovered.