]> Kevux Git Server - kevux-tools/commit
Update: Pass 0 to f_directory_remove() to avoid nftw() calls.
authorKevin Day <Kevin@kevux.org>
Sun, 13 Apr 2025 19:53:27 +0000 (14:53 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 13 Apr 2025 20:02:03 +0000 (15:02 -0500)
commit24189e2cd3fadf2dc1727410221c3ffd75e8e320
tree5fa6b538a39eae88de8ad0e0d3a63eaa988e7305
parent652dd36aced93465f530079b58a4ace167aca406
Update: Pass 0 to f_directory_remove() to avoid nftw() calls.

The `fl_directory_do()` already is taking care of the recursive delete.
The `f_directory_remove()` should not need to recurse.

The `nftw()` uses a lot of resources and slows down the speed even when the directory is empty.

The massif-visualizer shows that with `nftw()` there are two ~548.8 Kb spikes to remove empty directories.
Without the `nftw()` there is only a single 64Kb spike to remove the same empty directories.

The time taken with `nftw()` takes about 4e+06.
The time taken without `nftw()` takes about 1.6e+06.

The memory usage according to valgrind with `nftw()` is about 84 allocs, 84 frees, 3,303,959 bytes allocated.
The memory usage according to valgrind without `nftw()` is about 74 allocs, 74 frees, 497,999 bytes allocated.

The command I used to test this is:
```
clear ; md a/b/{c/d,e/f} && touch xxx && touch a/b/file.txt && valgrind remove a/b xxx -r ; t a
clear ; md a/b/{c/d,e/f} && touch xxx && touch a/b/file.txt && valgrind --tool=massif remove a/b xxx -r ; t a
```
sources/c/program/kevux/tools/remove/main/operate.c