draft/wip: lsdevinfo performance#97
Draft
nathanlynch wants to merge 7 commits into
Draft
Conversation
We can avoid spawning subprocesses by using the 'read' builtin. Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Use '!' for the substitution delimiter when manipulating path strings that contain '/'. This will make such code more amenable to mechanical transformations to come. Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
There is no reason to repeatedly spell out "/proc/device-tree". Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
The same work is performed to set the "slot" and "connection" variables in the vscsi and vfc loops; eliminate the duplication. Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
The "connection" variables are just the OF unit addresses (following the "@" in the node name). Use shell parameter expansion to efficiently extract these from variables containing the paths. Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Using redirection and the read builtin suffices.
[root@ltc-zz14-lp1 ~]# strace -q -f -c -e wait4,clone,execve,pipe2 /usr/sbin/lsdevinfo -F name
device:
name="env2"
device:
name="host0"
device:
name="sda"
/bin/ls: cannot access '/sys/devices/vio/30000004/host*': No such file or directory
device:
name="host1"
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
96.98 0.387740 1664 233 110 wait4
2.17 0.008676 70 123 clone
0.70 0.002815 37 75 execve
0.14 0.000567 7 81 pipe2
------ ----------- ----------- --------- --------- ----------------
100.00 0.399798 780 512 110 total
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
The pipeline is inefficient (multiple grep invocations) and
fragile (excluding names we're not interested in instead of just
specifying a name that matches what we want). Replace it with a shell
glob into an array.
[root@ltc-zz14-lp1 ~]# strace -q -f -c -e wait4,clone,execve,pipe2 lsdevinfo -F name
device:
name="env2"
device:
name="host0"
device:
name="sda"
/bin/ls: cannot access '/sys/devices/vio/30000004/host*': No such file or directory
device:
name="host1"
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
97.15 0.308000 1387 222 106 wait4
2.07 0.006572 56 116 clone
0.66 0.002080 29 70 execve
0.12 0.000384 5 75 pipe2
------ ----------- ----------- --------- --------- ----------------
100.00 0.317036 656 483 106 total
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Attempts at reducing the number of external processes spawned.
Work in progress for now, lightly tested.