You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not interleave readdir() calls with deletion of directory entries.
On macOS and some other non-Linux OSes, on some filesystems, readdir(dir) may
return NULL (with zero errno) after an entry in dir has been deleted. We thus
need to readdir() all directory entries before starting to delete them.
A benchmark (deleting 10 copies of the Linux kernel source) seems to show
that the new approach is approximately as fast as the previous one (slightly
faster on Linux, slightly slower on Mac), and in any case, is noticeably
faster than the system's /bin/rm.
Bazel's previous unix_jni DeleteTreesBelow implementation:
6.987 s (Linux/ext4); 89.44 s (Mac/APFS)
New Bazel unix_jni DeleteTreesBelow implementation:
6.971 s (Linux/ext4); 90.46 s (Mac/APFS)
`rm -rf`:
7.323 s (Linux/ext4); 99.09 s (Mac/APFS)
RELNOTES: None.
PiperOrigin-RevId: 346790610
0 commit comments