More optimizations of the ps command #23
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ps
command has been unbearably slow on floppy based systems because of excessive disk reads.The problem was partly fixed in the previous
ps
PR by replacing thegetpwent
open and read of the/etc/passwd
file once per line of output with a localgetpwent
-version that kept/etc/passwd
open. Good but still slow.The other contributor to the bad
ps
performance was the ttyname lookup, which opened and scanned the entire/dev
directory for every line out output. This version keeps the/dev
directory open and also optimizes the search for tty devices in several ways.ps
performance on floppy based systems with limited memory (such as L1 buffers only) is now quite good.Finally, while
ps
has always done some sanity checking of the kernel data read from memory, it has just exited silently when the data didn't make sense. This version adds more sanity checking and prints a message recommendingps
be recompiled if the expected kernel signature isn't found. Courtesy @ghaerr from the ELKS project.