Closed xirreal closed 8 months ago
Appreciate the effort, although it would've been nice if you had actually shown the difference apples to apples versus just showing you can delete Sea of Thieves in 800 ms, which isn't comparable to me deleting my FAST build cache in however long on my hardware. Especially if you are going to be rude about it, a little extra effort to more definitively show your solution is better would be nice.
Regardless didn't know this API existed and ~it looks promising~, thanks.
Hi - just chiming in, I recognize that spawning thousands of threads to delete files is a little silly, but this script is just something I hacked up in an afternoon because I was surprised the Windows APIs to delete files weren't faster.
Also - please consider that the slow part isn't the size of the files, it's the number of files - Sea of Thieves may be 100+GB, but it's only a few thousand files. So it's not surprising that the Windows shell APIs you used can delete it in under a second. I took some time to benchmark your tool against mine. I wrote a python script:
#!/usr/bin/env python3
import random
import os
import pathlib
num_files = int(input("number of files > "))
for i in range(0, num_files):
name = hex(random.getrandbits(128))[2:]
n = 8
name = os.path.sep.join(["files"] + [name[i:i+n] for i in range(0, len(name), n)])
pathlib.Path(os.path.dirname(name)).mkdir(parents=True, exist_ok=True)
f = open(name, 'w')
f.close()
to generate large numbers of empty files.
Here's how your tool fares against 30,000 empty files:
Here's this repo:
Feel free to test this yourself. Because of the overhead of spawning the thousands of threads, I am not surprised that for directories with a small number of files (like Sea of Thieves) the Windows shell APIs are faster.
I do recognize I was rude and will remove the negative remarks from my repo as they were totally uncalled for, I apologize. I also plan to do more extensive testing, but it does make sense that the bottleneck is the amount of files, I didn't even think about that. It actually kinda bothers me that Windows fails this bad...
@xirreal honestly I completely understand, we were also skeptical about our approach but as far as we know this is the best way on Windows to handle deleting files with this specific topology. I probably should have emphasized that the benefit of this tool scales with file count/depth more than size. That's the reason I chose the example I did was because it had 26k files in 20k folders with moderate nesting (only 256 top level folders).
But that being said there's some benefit to being imprecise/broad in a video because it motivates people to correct you and find a better way, which in the end helps me since I want to delete things as fast as possible 😆
C:\trash>nmuidi.exe download
Cleaning download
Total time: 2.2589607s
C:\trash>win-fast-rm.exe "download - Copy"
Deleted "C:\trash\download - Copy"(29.70 GB) successfully in: 5814.181ms
For me nmuidi is also faster I tested it on my copied Downloads folder with 29.7 GB of some actual real-world data like .iso, .exe, .png, .zip files, unzipped folders with files and whatnot
https://github.com/uwu/win-fast-rm