Today I wanted to clear my trash bin on my Mac, but unfortunately it contained one or two node_modules directories. Deleting them caused the operating system to freeze. I needed to find a way to delete them anyways to free up space, so I moved the offenders out of the trash bin and tried good old rm -rf. Just as slow. Weird...
I started googling around and found this hack using rsync --delete. Amazingly, it made quick work of the problem. Surprising that something as simple as deleting a bunch of files is so unoptimized on one of the largest operating systems available. Even deleting using rm -rf target was impossibly slow on these. I suppose it avoids keeping list of all the targets and instead greedily deletes whatever it finds on each iteration.