-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
on macOS, std.fs.deleteTree()
is 40% slower than rm -rf
#13048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I get similar results on Linux:
(tested with the folder that resulted from
Zig:
Worth noting that |
As far as I can tell, the extra syscalls come from two sources:
I'm not totally sure if these are addressable given the non-allocating, single-open-fd API of |
why allocate when the function can be made recursive? (without reading the source) I would assume its a recursive function given the nature of the operation. was it to save on open file descriptors? stack overflow? going with recursion the non-allocating aspect can definitely be preserved |
An interesting note from
I wonder what the perf impact here is if we go depth-first instead of breadth-first |
Not totally sure, but there is this comment: Lines 2099 to 2101 in ff534d2
I would assume it's to avoid stack overflow |
recursion is just a different form of allocation. It allocates on the stack instead of the heap. |
having |
My attempt at a recursive implementation ended up being slightly faster than my system's
PR here: #13070 EDIT: Just-as-fast but non-recursive implementation here: #13073 |
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.10.0-dev.2822+b79884eaf
Steps to Reproduce
Zig (
zig build-exe -OReleaseFast rm.zig
)C (
clang -O3 rm.c
) usingremovefile
(which turns out to be slower or the same asrm
)Assuming
node_modules
is a folder with lots and lots of files and directories (~700 MB, xxx,xxx files)Expected Behavior
Zig should perform similarly or better
Actual Behavior
The text was updated successfully, but these errors were encountered: