Skip to content
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

draft/wip: lsdevinfo performance #97

Draft
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

nathanlynch
Copy link
Contributor

Attempts at reducing the number of external processes spawned.

Work in progress for now, lightly tested.

We can avoid spawning subprocesses by using the 'read' builtin.

Signed-off-by: Nathan Lynch <[email protected]>
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 <[email protected]>
There is no reason to repeatedly spell out "/proc/device-tree".

Signed-off-by: Nathan Lynch <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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