fd icon indicating copy to clipboard operation
fd copied to clipboard

fd is 4x slower(even 167x slower) than find when to delete files

Open winter-loo opened this issue 4 months ago • 2 comments

Test case: delete 15369 files from a directory

See the ad-hoc tests in the image:

Image

Amazing to find 'find with -delete option' is so fast.

fd version: 10.2.0 find version: 4.5.11

winter-loo avatar Aug 20 '25 02:08 winter-loo

One obvious reason is that fd is spawning a new process for every file, whereas find makes the syscall directly with the -delete flag. Using the --exec-batch option to pass all the files to rm at once instead of executing rm individually for each would probably help.

Although I don't know why find with -exec rm is so much faster.

tmccombs avatar Aug 20 '25 13:08 tmccombs

Although I don't know why find with -exec rm is so much faster.

I'm guessing it's because fd runs them in parallel, but there may be some kernel/fs contention when deleting inodes. Is fd faster with -j1?

tavianator avatar Nov 04 '25 13:11 tavianator