|
1 | 1 | #!/usr/bin/perl |
2 | 2 |
|
3 | 3 | $ARGC=scalar @ARGV; |
4 | | -if($ARGC != 1){ |
5 | | - print "Usage: <script.pl> <filename.csv>\n"; |
| 4 | +if($ARGC < 1){ |
| 5 | + print "Usage: <script.pl> <filename.csv> <options>\n"; |
| 6 | + print "Options:\n"; |
| 7 | + print " -is_state_dump The file is a margo state dump\n"; |
6 | 8 | exit -1; |
7 | 9 | } |
8 | 10 |
|
9 | 11 | $file = $ARGV[0]; |
| 12 | + |
| 13 | +$is_state_dump=0; |
| 14 | +for($i=1;$i<$ARGC;$i++){ |
| 15 | + if($ARGV[$i] == "-is_state_dump"){ #file is generated by a margo state dump |
| 16 | + $is_state_dump = 1; |
| 17 | + } |
| 18 | +} |
| 19 | + |
10 | 20 | open(IN, $file); |
11 | 21 |
|
12 | 22 | #cf https://xgitlab.cels.anl.gov/sds/margo/blob/master/doc/instrumentation.md#generating-a-profile-and-topology-graph |
|
15 | 25 | $i=0; |
16 | 26 | $nrpc; |
17 | 27 | %rpcnames = (); |
| 28 | +$active = 1; |
| 29 | +if($is_state_dump == 1){ #not active from the start |
| 30 | + $active = 0; |
| 31 | +} |
18 | 32 |
|
19 | 33 | while(<IN>){ |
20 | 34 | $line=$_; |
21 | | - if($i==0){ |
22 | | - if(!($line=~m/(\d+)/)){ |
23 | | - print "Could not parse number of RPC names from line $line\n"; |
24 | | - exit -1; |
25 | | - }else{ |
26 | | - $nrpc = $1; |
27 | | - print "$nrpc RPCs\n"; |
28 | | - } |
29 | | - }elsif($i==1){ |
30 | | - if(!($line=~m/\d+\,(.*)/)){ |
31 | | - print "Could not parse server IP from line $line\n"; |
32 | | - exit -1; |
33 | | - }else{ |
34 | | - $ip = $1; |
35 | | - print "IP $ip\n"; |
36 | | - } |
37 | | - }elsif($i>=2 && $i<2+$nrpc){ |
38 | | - if(!($line=~m/(\w+)\,(.*)/)){ |
39 | | - print "Could not parse RPC hash/name from line $line\n"; |
40 | | - exit -1; |
41 | | - }else{ |
42 | | - $hash = $1; |
43 | | - $name = $2; |
44 | | - print "$name -> $hash\n"; |
45 | | - $rpcnames{"$hash"} = $name; |
46 | | - } |
47 | | - }elsif( ($i -2 - $nrpc) % 2 == 0){ |
48 | | - #Even lines format is hash, avg, rpc_breadcrumb, addr_hash, origin_or_target, cumulative, _min, _max, count, abt_pool_size_hwm, abt_pool_size_lwm, abt_pool_size_cumulative, abt_pool_total_size_hwm, abt_pool_total_size_lwm, abt_pool_total |
49 | 35 |
|
50 | | - @vals = split('\s*,\s*', $line); |
51 | | - if(scalar @vals != 15){ |
52 | | - print "Could not parse data line $line\n"; |
53 | | - exit -1; |
54 | | - } |
55 | | - $hash = $vals[0]; |
56 | | - if(!(exists $rpcnames{$hash})){ |
57 | | - print "Could not find hash '$hash' in map\n"; |
58 | | - exit -1; |
59 | | - } |
60 | | - $name = $rpcnames{$hash}; |
61 | | - $avg = $vals[1]; |
62 | | - $count = $vals[8]; |
63 | | - $total = $vals[5]; |
64 | | - $loc = $vals[4]; |
65 | | - print "Func $name Origin/Target $loc Avg $avg Count $count Total $total\n"; |
| 36 | + if($active == 1){ |
| 37 | + if($is_state_dump == 1 && $line=~m/^$/){ |
| 38 | + $active = 0; |
| 39 | + }elsif($i==0){ |
| 40 | + if(!($line=~m/(\d+)/)){ |
| 41 | + print "Could not parse number of RPC names from line $line\n"; |
| 42 | + exit -1; |
| 43 | + }else{ |
| 44 | + $nrpc = $1; |
| 45 | + print "$nrpc RPCs\n"; |
| 46 | + } |
| 47 | + }elsif($i==1){ |
| 48 | + if(!($line=~m/\d+\,(.*)/)){ |
| 49 | + print "Could not parse server IP from line $line\n"; |
| 50 | + exit -1; |
| 51 | + }else{ |
| 52 | + $ip = $1; |
| 53 | + print "IP $ip\n"; |
| 54 | + } |
| 55 | + }elsif($i>=2 && $i<2+$nrpc){ |
| 56 | + if(!($line=~m/(\w+)\,(.*)/)){ |
| 57 | + print "Could not parse RPC hash/name from line $line\n"; |
| 58 | + exit -1; |
| 59 | + }else{ |
| 60 | + $hash = $1; |
| 61 | + $name = $2; |
| 62 | + print "$name -> $hash\n"; |
| 63 | + $rpcnames{"$hash"} = $name; |
| 64 | + } |
| 65 | + }elsif( ($i -2 - $nrpc) % 2 == 0){ |
| 66 | + #Even lines format is hash, avg, rpc_breadcrumb, addr_hash, origin_or_target, cumulative, _min, _max, count, abt_pool_size_hwm, abt_pool_size_lwm, abt_pool_size_cumulative, abt_pool_total_size_hwm, abt_pool_total_size_lwm, abt_pool_total |
| 67 | + |
| 68 | + @vals = split('\s*,\s*', $line); |
| 69 | + if(scalar @vals != 15){ |
| 70 | + print "Could not parse data line $line\n"; |
| 71 | + exit -1; |
| 72 | + } |
| 73 | + $hash = $vals[0]; |
| 74 | + if(!(exists $rpcnames{$hash})){ |
| 75 | + print "Could not find hash '$hash' in map\n"; |
| 76 | + exit -1; |
| 77 | + } |
| 78 | + $name = $rpcnames{$hash}; |
| 79 | + $avg = $vals[1]; |
| 80 | + $count = $vals[8]; |
| 81 | + $total = $vals[5]; |
| 82 | + $loc = $vals[4]; |
| 83 | + print "Func $name Origin/Target $loc Avg $avg Count $count Total $total\n"; |
| 84 | + } |
| 85 | + $i++; |
| 86 | + }elsif($line=~m/Margo RPC profiling/){ |
| 87 | + #read 6 lines |
| 88 | + for($ii=0;$ii<6;$ii++){ |
| 89 | + <IN>; |
| 90 | + } |
| 91 | + $active = 1; |
66 | 92 | } |
67 | | - $i++; |
68 | 93 | } |
| 94 | + |
| 95 | +close(IN); |
0 commit comments