Show HN: Rmbrr – Rust 实现的并行目录删除工具
1 分•作者: mtopo•7 个月前
我厌倦了等待 node_modules 目录删除,所以我开发了 rmbrr。在我的电脑上,它比 rimraf 在 Windows 上快 44%(1.8 秒 vs 3.2 秒),在 WSL 上快 61%(192 毫秒 vs 660 毫秒)。
实现方法:单次递归扫描构建依赖关系图,然后并行工作者自底向上删除。一旦一个目录的最后一个子项完成,它就会自动排队等待删除。
在 Windows 上,我使用 POSIX 删除语义(通过 SetFileInformationByHandle 的 FILE_DISPOSITION_POSIX_SEMANTICS),这可以立即删除命名空间,并处理只读/正在使用的文件,无需重试循环。
在 Unix 上,使用相同的并行架构和标准系统调用。
使用 Rust 编写,以原生二进制文件的形式发布,并可选地提供 npm/brew/cargo,方便安装。
GitHub: [https://github.com/mtopolski/rmbrr](https://github.com/mtopolski/rmbrr)
npm: [https://www.npmjs.com/package/rmbrr](https://www.npmjs.com/package/rmbrr)
基准测试的详细信息在 README 中 - 在 28K+ 文件的 node_modules 目录上进行了测试。
查看原文
I got tired of waiting for node_modules to delete, so I built rmbrr. On my box it takes 44% less time than rimraf on Windows (1.8s vs 3.2s) and 61% less time on WSL (192ms vs 660ms).<p>The approach: single-pass recursive scan builds a dependency graph, then parallel workers delete bottom-up. As soon as a directory's last child completes, it's automatically queued for deletion.<p>On Windows, I use POSIX delete semantics (FILE_DISPOSITION_POSIX_SEMANTICS via SetFileInformationByHandle) which gives immediate namespace removal and handles read-only/in-use files without retry loops.<p>On Unix, same parallel architecture using standard syscalls.<p>Written in Rust, ships as a native binary with optional npm/brew/cargo for easy installation.<p>GitHub: <a href="https://github.com/mtopolski/rmbrr" rel="nofollow">https://github.com/mtopolski/rmbrr</a>
npm: <a href="https://www.npmjs.com/package/rmbrr" rel="nofollow">https://www.npmjs.com/package/rmbrr</a><p>Benchmark details in README - tested on 28K+ file node_modules directories.