show_gids: Fix slow run on hosts with many interfaces#58
Conversation
3775437 to
4768504
Compare
On some hosts, script could run for many minutes. Reason : On host with many NICs, each interface is scanned unordered with all the GIDs. Add: 1. Flag --slim - order the GID table, count number of empty GIDs, break from loop once number of empty GIDs is larger than predefined MAX (2). Explanation: GIDs are assigned in order, if GID is empty, it means all the following GIDs will be empty as well. Exception: if some GID index was freed and new GID was assigned, there might be holes. 2. Flag --dev - show_gids used to get device as an optional only argument. As there is additional argument now, need dedicated option to allow several arguments. 3. Add help Result: By default - script will run as before - will scan all GIDs --slim should be used for large scale to allow reasonable timed run.
| echo -e "DEV\tPORT\tINDEX\tGID\t\t\t\t\tIPv4 \t\tVER\tDEV" | ||
| echo -e "---\t----\t-----\t---\t\t\t\t\t------------ \t---\t---" | ||
| DEVS=$1 | ||
| #Break after predefined number of 0 GIDS found |
There was a problem hiding this comment.
Add a space between "#" and comment:
# Break after...
# Assuming..
# Needed on host ..
| #Break after predefined number of 0 GIDS found | ||
| #Assuming that the rest will be zero as well | ||
| #Needed on hosst with large number of NICs, to avoid script slow run | ||
| MAX_NUM_OF_ZERO_GIDS=2 |
There was a problem hiding this comment.
Why we need this, istead of break on first zero gid?
There was a problem hiding this comment.
Per my experience with holes in git table, we have seen such issue recently. During ib_write_bw run if link is toggled, a hole will be created. Reasonable assumption is if there is a hole, most of the times it will be small, not in higher indexes. Thus the idea of scanning several more GIDs after the hole, it will not increase total time by much, but will account for most of the cases with holes.
MarkZhang81
left a comment
There was a problem hiding this comment.
Need to support "-h" and "--help";
Add a usage() function to print usage;
Make sure the program exit with 0 when it succeeds, and non-0 when it fails. Can check with "echo $?". For example:
$ ./sbin/show_gids -m
DEV PORT INDEX GID IPv4 VER DEV // This line is not needed in this case
--- ---- ----- --- ------------ --- --- // same with this line
show_gids will print gids table for all RDMA devices
-d|--dev= Can choose specifci mlx devices
-s|--slim will break gid table scan after predefine max num-2 of zero GIDs
[markzhang@c-236-0-180-183 mlnx-tools]$ echo $?
1
For your reference the output could be:
$ show_gids -h
Show all gid entries.
Usage: show_gids [ OPTIONS ]
[-d, --dev=<rdma_dev>]: Show git entries of a specific rdma device
[-s, --slim]: Show git entries in a fast way: stop checking left gid entries when a 0 gid is encountered
[-h, --help]: Show help
On a unsupported parameter, e.g.:
$ show_gids -m
Unsupported parameter "-m".
Usage: show_gids [ OPTIONS ]
[-d, --dev=<rdma_dev>]: Show git entries of a specific rdma device
[-s, --slim]: Show git entries in a fast way: stop checking left gid entries when a 0 gid is encountered
[-h, --help]: Show help
|
I agree with the idea of more organizes parameters and help, but this change main goal was to reduce run time on large scale. The only reason I added these options was due to the fact that show_gids was assuming that only parameter can be device. As I had to change that, I added a bit more. I cannot guarantee I will have time for adding all you suggest, but I will try. If not - this part can be improved in separate commit by anyone :) |
On some hosts, script could run for many minutes.
Reason : On host with many NICs, each interface is scanned unordered with all the GIDs.
Fix: Order the GID table, break from loop once empty GID is found. Explanation: GIDs are assigned in order, if GID is empty, it means all the following will be empty as well