diff options
Diffstat (limited to 'security/nss/cmd/ttformat')
-rw-r--r-- | security/nss/cmd/ttformat/Makefile | 74 | ||||
-rw-r--r-- | security/nss/cmd/ttformat/manifest.mn | 48 | ||||
-rwxr-xr-x | security/nss/cmd/ttformat/nClient | 49 | ||||
-rwxr-xr-x | security/nss/cmd/ttformat/nServ | 49 | ||||
-rwxr-xr-x | security/nss/cmd/ttformat/redux.pl | 77 | ||||
-rw-r--r-- | security/nss/cmd/ttformat/reduxhwm.pl | 33 | ||||
-rw-r--r-- | security/nss/cmd/ttformat/ttformat.c | 135 |
7 files changed, 465 insertions, 0 deletions
diff --git a/security/nss/cmd/ttformat/Makefile b/security/nss/cmd/ttformat/Makefile new file mode 100644 index 000000000..f2a407990 --- /dev/null +++ b/security/nss/cmd/ttformat/Makefile @@ -0,0 +1,74 @@ +#! gmake +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### +include ../platlibs.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + +include ../platrules.mk + diff --git a/security/nss/cmd/ttformat/manifest.mn b/security/nss/cmd/ttformat/manifest.mn new file mode 100644 index 000000000..d743cfb1c --- /dev/null +++ b/security/nss/cmd/ttformat/manifest.mn @@ -0,0 +1,48 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +CORE_DEPTH = ../../.. + +DEFINES += -DNSPR20 + +# MODULE public and private header directories are implicitly REQUIRED. +MODULE = security + +CSRCS = ttformat.c + +# The MODULE is always implicitly required. +# Listing it here in REQUIRES makes it appear twice in the cc command line. +REQUIRES = seccmd dbm + +PROGRAM = ttformat + diff --git a/security/nss/cmd/ttformat/nClient b/security/nss/cmd/ttformat/nClient new file mode 100755 index 000000000..aab8402bd --- /dev/null +++ b/security/nss/cmd/ttformat/nClient @@ -0,0 +1,49 @@ +# /bin/ksh +# +# nClient -- run the nss test strsclnt for performance testing +# +# syntax: nClient [options] +# +# where: options are: +# any valid command line option for strsclnt +# Note that some options are set by this script! +# +# Description: +# nClient runs the nss test program "strsclnt" for purposes of +# gathering performance data. +# +# some shell variables are set at the top of the script +# you may have to change these, depending on the host you +# are running on and other "stuff". caveat emptor. +# +# You will have to tinker with this script to get it to +# run for you. +# +# See also: nServ +# +# --- begin nClient ------------------------------------------------------- +baseDir=/home/lorenzo/nss-raw/mozilla +# +# shell variables for running strsclnt +# +export HOST=`hostname -s` +export DOMSUF=red.iplanet.com +serverHost=dbldog +nssDB=${baseDir}/tests_results/security/${HOST}.1/client +nssHost=${HOST}.red.iplanet.com +pushd ${baseDir}/security/nss/tests/common +objDir=`gmake objdir_name` +popd +# +# +nssOptions="-p 12944 ${serverHost}.red.iplanet.com" +export LD_LIBRARY_PATH=${baseDir}/dist/${objDir}/lib +clientProg=${baseDir}/security/nss/cmd/strsclnt/${objDir}/strsclnt +# +# do the test +# +nssCommand="${clientProg} -d ${nssDB} ${nssOptions}" +echo $nssCommand $* +${nssCommand} $* & +# +# --- end nClient -------------------------------------------------------- diff --git a/security/nss/cmd/ttformat/nServ b/security/nss/cmd/ttformat/nServ new file mode 100755 index 000000000..ddf51b0e8 --- /dev/null +++ b/security/nss/cmd/ttformat/nServ @@ -0,0 +1,49 @@ +# /bin/ksh +# +# nServ -- run the nss test selfserv for performance testing +# +# syntax: nServ [options] +# +# where: options are: +# Valid arguments to the selfserv program +# Note that this script sets some options +# +# Description: +# nServ runs the nss test program "selfserv" for purposes of +# gathering performance data. +# +# some shell variables are set at the top of the script +# you may have to change these, depending on the host you +# are running on and other "stuff". caveat emptor. +# +# See also: nClinet +# +# --- begin nServ ------------------------------------------------------- +# +baseDir=/home/lorenzo/nss-server/mozilla +# +# shell variables for running selfserv +# +export HOST=`hostname -s` +export DOMSUF=red.iplanet.com +nssDB=${baseDir}/tests_results/security/${HOST}.1/server +nssHost=${HOST}.red.iplanet.com +nssOptions="-p 12944 -w nss" +pushd ${baseDir}/security/nss/tests/common +objDir=`gmake objdir_name` +popd +export LD_LIBRARY_PATH=${baseDir}/dist/${objDir}/lib +# +# shell variables for capturing instrumentation data +# +export NSPR_LOG_MODULES=TestCase:6 +export NSPR_LOG_FILE=xxxLogfile +# +# do the test +# +nssCommand="${baseDir}/dist/${objDir}/bin/selfserv -d ${nssDB} -n ${nssHost} ${nssOptions}" +echo $nssCommand +${nssCommand} $* & +# xxgdb ${baseDir}/dist/${objDir}/bin/selfserv +# +# --- end nServ ------------------------------------------------------- diff --git a/security/nss/cmd/ttformat/redux.pl b/security/nss/cmd/ttformat/redux.pl new file mode 100755 index 000000000..ccc13c24a --- /dev/null +++ b/security/nss/cmd/ttformat/redux.pl @@ -0,0 +1,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); diff --git a/security/nss/cmd/ttformat/reduxhwm.pl b/security/nss/cmd/ttformat/reduxhwm.pl new file mode 100644 index 000000000..f442ff4e4 --- /dev/null +++ b/security/nss/cmd/ttformat/reduxhwm.pl @@ -0,0 +1,33 @@ +# +# reduxhwm.pl -- analyze highwatermark data in xxxLogfile +# +# example interesting line in xxxLogfile +# 1026[8154da0]: selfserv: Launched thread in slot 37, highWaterMark: 63 +# +# +# +while ( <STDIN> ) { + chomp; + ($proc, $who, $launched, $thread, $in, $slotx, $slot, $hwm, $highwatermark) = split; + if ( $launched == "Launched" ) { + next if ( $slot == 0 ); + $notInteresting++; + if ( $hwmMax < $highwatermark ){ + $hwmMax = $highwatermark; + } + $hwmArray[$slot] += 1; + $interesting++; + } +} # end while() + +printf ("Interesteing: %d\n", $interesting ); +printf ("Not Interesting: %d\n", $notInteresting - $interesting ); + +foreach $element (@hwmArray) { + $percent = 100*($element / $interesting); + $percentTotal += $percent; + printf("Slot %2d: %d hits, %2.2f percent, %2.2f total percent\n", $i, $element, $percent, $percentTotal ); + $i++; +} +printf("Sum of percentages: %3.2f\n", $percentTotal ); +# --- end --- diff --git a/security/nss/cmd/ttformat/ttformat.c b/security/nss/cmd/ttformat/ttformat.c new file mode 100644 index 000000000..7fcf04f86 --- /dev/null +++ b/security/nss/cmd/ttformat/ttformat.c @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +/* +** File: ttformat.c +** Description: ttformat.c reads the file "xxxTTLog". xxxTTLog +** contains fixed length binary data written by nssilock. +** ttformat formats the data to a human readable form (printf) +** usable for visual scanning and for processing via a perl script. +** Output is written to stdout +** +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <nssilock.h> + +/* +** struct maps enum nssILockType to character representation +*/ +struct { + nssILockType ltype; + char *name; +} ltypeNameT[] = { + { nssILockArena, "Arena" }, + { nssILockSession, "Session" }, + { nssILockObject, "Object" }, + { nssILockRefLock, "RefLock" }, + { nssILockCert, "Cert", }, + { nssILockCertDB, "CertDB" }, + { nssILockDBM, "DBM" }, + { nssILockCache, "Cache" }, + { nssILockSSL, "SSL" }, + { nssILockList, "List" }, + { nssILockSlot, "Slot" }, + { nssILockFreelist, "Freelist" }, + { nssILockOID, "OID" }, + { nssILockAttribute, "Attribute" }, + { nssILockPK11cxt, "PK11Context" }, + { nssILockRWLock, "RWLock" }, + { nssILockOther, "Other" }, + { nssILockSelfServ, "SelfServ" } +}; /* end ltypeNameT */ + +/* +** struct maps enum nssILockOp to character representation +*/ +struct { + nssILockOp op; + char *name; +} opNameT[] = { + { FlushTT, "FlushTT" }, + { NewLock, "NewLock" }, + { Lock, "Lock" }, + { Unlock, "Unlock" }, + { DestroyLock, "DestroyLock" }, + { NewCondVar, "NewCondVar" }, + { WaitCondVar, "WaitCondVar" }, + { NotifyCondVar, "NotifyCondVar" }, + { NotifyAllCondVar, "NotifyAllCondVar" }, + { DestroyCondVar, "DestroyCondVar" }, + { NewMonitor, "NewMonitor" }, + { EnterMonitor, "EnterMonitor" }, + { ExitMonitor, "ExitMonitor" }, + { Notify, "Notify" }, + { NotifyAll, "NotifyAll" }, + { Wait, "Wait" }, + { DestroyMonitor, "DestroyMonitor" } +}; /* end opNameT */ + + +int main(int argc, char *argv[]) +{ + FILE *filea; + struct pzTrace_s inBuf; + char *opName; + char *ltypeName; + int rCount = 0; + int oCount = 0; + + filea = fopen( "xxxTTLog", "r" ); + if ( NULL == filea ) { + fprintf( stderr, "ttformat: Oh drat! Can't open 'xxxTTLog'\n" ); + exit(1); + } + + while(1 == (fread( &inBuf, sizeof(inBuf), 1 , filea ))) { + ++rCount; + if ( inBuf.op > DestroyMonitor ) continue; + if ( inBuf.op < FlushTT ) continue; + + opName = opNameT[inBuf.op].name; + ltypeName = ltypeNameT[inBuf.ltype].name; + + ++oCount; + printf("%8d %18s %18s %6d %6d %12p %6d %20s\n", + inBuf.threadID, opName, ltypeName, inBuf.callTime, inBuf.heldTime, + inBuf.lock, inBuf.line, inBuf.file ); + } /* end while() */ + + fprintf( stderr, "Read: %d, Wrote: %d\n", rCount, oCount ); + return 0; +} /* main() */ +/* end ttformat.c */ |