-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chmod:fix file descriptor limits issue #9595
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
base: main
Are you sure you want to change the base?
Conversation
Replace recursive safe_traverse_dir with iterative depth-first search using a stack to prevent file descriptor exhaustion during deep directory hierarchies. Also collect read_dir entries upfront to release the directory iterator early, reducing resource usage.
Use rlimit crate's .limit() method instead of manual libc rlimit calls for constraining NOFILE. This cleans up the test code and leverages existing utilities in the rlimit crate. Additionally, optimize import by using PathBuf directly from std::path.
|
GNU testsuite comparison: |
…type Use implicit import for PathBuf to simplify code readability.
|
GNU testsuite comparison: |
- Add new SMACK test job to GnuTests.yml with corresponding environment variables - Remove unused dependencies (autopoint, texinfo, rustfmt) from CI jobs - Enhance disk space management in CICD.yml by cleaning additional directories and adding df -h for monitoring - Update spell-checker ignores to include zstd and cpio - Add test for stty --all option to validate output parsing These changes expand test coverage for security modules and improve CI efficiency by reducing disk usage and streamlining dependencies.
# Conflicts: # src/uu/chmod/src/chmod.rs
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
… chown executors Use match expressions for metadata retrieval to improve readability and reduce nesting. Hoist variable declarations for better scope management in ChownExecutor. These changes enhance code clarity without altering functionality.
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
|
||
| let entries = dir_fd.read_dir()?; | ||
| // Depth-first traversal without recursive calls to avoid stacking FDs. | ||
| let mut stack: Vec<(DirFd, PathBuf)> = vec![(dir_fd, dir_path.to_path_buf())]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you look at the impact on the memory ?
Add dev-dependencies (divan, tempfile, uucore with benchmark features) and a bench target for chmod_bench to enable performance benchmarking. This allows measuring and optimizing the chmod utility's efficiency.
- Added uu_chmod to the list of packages in the benchmarks workflow matrix to include it in performance testing alongside other utilities.
…trlimit calls Wrap System allocator method calls (alloc, dealloc, realloc) and getrlimit in explicit unsafe blocks to satisfy Rust safety requirements and potential linting rules, improving code clarity in the benchmark file.
Merging this PR will degrade performance by 27.39%
Performance Changes
Comparing Footnotes
|
Reorder divan and uucore::libc imports to alphabetical order for improved code consistency and readability.
|
GNU testsuite comparison: |
Replace `&mut lim as *mut _` with `&raw mut lim` to use the newer, more explicit Rust syntax for creating raw mutable pointers. This improves code clarity and aligns with modern Rust idioms.
- Updated multiple crates including aho-corasick, anstream, anstyle, bitflags, unicode-ident, uuid, and others to their latest versions - Added toml_parser crate as a new dependency - Added codspeed-divan-compat and tempfile to uu_chmod dependencies - This ensures compatibility, security fixes, and latest features from upstream crates
|
GNU testsuite comparison: |
As mentioned in the comment below, it hits the file descriptor limit.
#9554 (comment)
Make adjustments to reduce the use of FD.