-
Notifications
You must be signed in to change notification settings - Fork 421
Do not scan through all PIDs to find parent PID command #817
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: master
Are you sure you want to change the base?
Conversation
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.
ps does not support the -q flag on MacOS. This can't be merged as is.
Can you post some timing info (time ps -o comm= -p "$PPID") from the situations that you think this is slow?
If this is really a problem, we could try to have two different paths for those that support the -q flag vs those that don't.
|
Oops, |
|
I'm probably missing something, but why was a separate option added? If |
|
I'm not sure why
after running 1000 If different code paths for different systems are possible, then |
What file are you proposing to read? If you want to try to implement it, here are a few tips:
|
Since the quick mode option -q is not portable, portable scripts cannot use it. Tweak the behavior of -p to use the quick mode if no conflicting options are specified. Inspired by liquidprompt/liquidprompt#817
|
This approach might be obsolete with the next version of ps, see https://gitlab.com/procps-ng/procps/-/commit/7f80362b9ff8cb2b699a01e06a70972a4ae9399f |
|
Nice! Thanks for making that PR, and then bringing it to our attention. Hopefully it will propagate to distros soon. |
There's one command that takes a long time after profiling bash startup.
We currently scan though all processes just to find out $PPID command.
The time to do it grows linearly with a number of processes running.
Let's fix that.
Compare:
strace -e openat ps -o comm= -p $PPIDvs
strace -e openat ps -o comm= -q $PPIDTechnical checklist:
IFS_LP_FIRST_INDEX_LP_PERCENT_LP_SHELL_*)tests/test_*.shfiles)tests.shshellcheck.sh(requires shellcheck)... versionadded:: X.Yor.. versionchanged:: Y.Zdocs/docs-lint.sh(requires Python 3 andrequirements.txtinstalled (
cd docs/; python3 -m venv venv; . venv/bin/activate; pip install -r requirements.txt))