Skip to content

pwdx: read only the requested processes - #865

Open
KrushnXGIT wants to merge 1 commit into
uutils:mainfrom
KrushnXGIT:pwdx-only-given-pids
Open

KrushnXGIT wants to merge 1 commit into
uutils:mainfrom
KrushnXGIT:pwdx-only-given-pids

Conversation

@KrushnXGIT

Copy link
Copy Markdown

pwdx used System::new_all(), which reads every process on the system (command line, environment, memory...) and the CPU and memory stats, only to print the working directory of the given pids. With 2000 processes running, one pwdx call takes 100 ms.

This refreshes just each requested process, and only its working directory.

2158 processes procps-ng main this PR
pwdx PID 0.57 ms 99.1 ms 1.1 ms
pwdx with 200 pids 2.4 ms 100.5 ms 6.7 ms

hyperfine, 20 runs, release builds. Output and exit code are unchanged for valid, missing, zombie, invalid and /proc/PID arguments, as user and as root; the existing tests cover these cases.

To find the working directory of a few processes, pwdx loaded every process on the system with all its details through System::new_all(). Refresh just each requested process, and only its working directory.
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.32%. Comparing base (67832aa) to head (17f38e3).
⚠️ Report is 61 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/pwdx/src/pwdx.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #865      +/-   ##
==========================================
+ Coverage   19.20%   20.32%   +1.12%     
==========================================
  Files          68       68              
  Lines       10156    10126      -30     
  Branches      546      551       +5     
==========================================
+ Hits         1950     2058     +108     
+ Misses       8206     8068     -138     
Flag Coverage Δ
macos_latest 7.10% <0.00%> (+0.35%) ⬆️
ubuntu_latest 20.71% <0.00%> (+1.15%) ⬆️
windows_latest 0.02% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant