1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#
# redux.pl -- general nss trace data extraction
#
# syntax: redux.pl
#
# redux.pl reads a file of formatted trace table records from stdin
# The trace records are formatted by nssilock.c
# redux.pl parses the lines and accumulates data in a hash
# When finished with stdin, redux.pl traverses the hash and emits
# the accumulated data.
#
# Operation:
# read stdin, accumulate in a hash by file, line, type.
# traverse the hash, reporting data.
#
# raw data format:
# thredid op ltype callTime heldTime lock line file
#
# Notes:
# After running redux.pl, sort the report on column 4 in decending sequence
# to see where the lock contention is.
#
#
# -----------------------------------------------------------------------
use Getopt::Std;
getopts("h") || die "redux.pl: unrecognized command option";
# -----------------------------------------------------------------------
# read stdin to exhaustion
while ( <STDIN> ) {
$recordCount++;
# next if ($recordCount < 36000 ); # skip initialization records
chomp;
($thredid, $op, $ltype, $callTime, $heldTime, $lock, $line, $file) = split;
# select out un-interesting lines
# next if (( $callTime < $opt_c ) && ( $heldTime < $opt_h ));
# print $_, "\n";
# count general stats
$interesting++;
# format the key
$hashKey = $file ." ". $line ." ". $ltype;
# Update the data in the hash entry
$theData = $theHash{$hashKey}; # read it if it already exists
( $hCount, $hcallTime, $hheldTime, $hcallMax, $hheldMax ) = split(/\s+/, $theData );
$hCount++;
$hcallTime += $callTime;
$hheldTime += $heldTime;
$hcallMax = ( $hcallMax > $callTime )? $hcallMax : $callTime;
$hheldMax = ( $hheldMax > $heldTime )? $hheldMax : $heldTime;
# Write theData back to the hash
$theData = $hCount." ".$hcallTime." ".$hheldTime." ".$hcallMax." ".$hheldMax;
$theHash{$hashKey} = $theData;
} # end while()
# -----------------------------------------------------------------------
# traverse theHash
printf("%-16s %6s %-16s %8s %8s %8s %8s %8s\n",
"File","line","ltype","hits","calltim","heldtim","callmax","heldmax" );
while (($hashKey,$theData) = each(%theHash)) {
$hashElements++;
($file, $line, $ltype) = split(/\s+/, $hashKey );
( $hCount, $hcallTime, $hheldTime, $hcallMax, $hheldMax ) = split(/\s+/, $theData );
printf("%-16s %6d %-16s %8d %8d %8d %8d %8d\n",
$file, $line, $ltype, $hCount, $hcallTime, $hheldTime, $hcallMax, $hheldMax );
} # end while()
# -----------------------------------------------------------------------
# dump global statistics
printf ("Record count: %d\n", $recordCount );
printf("Interesting: %d, HashElements: %d\n", $interesting, $hashElements);
|