[Swift-commit] r4006 - usertools/worker-profile
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Thu Jan 20 09:35:55 CST 2011
Author: wozniak
Date: 2011-01-20 09:35:55 -0600 (Thu, 20 Jan 2011)
New Revision: 4006
Added:
usertools/worker-profile/worker_jobs.zsh
usertools/worker-profile/worker_jobs_duration.zsh
usertools/worker-profile/worker_jobs_lib.zsh
usertools/worker-profile/worker_profile_extract.zsh
usertools/worker-profile/worker_profile_util.zsh
Log:
Import worker profile plot data tools
Added: usertools/worker-profile/worker_jobs.zsh
===================================================================
--- usertools/worker-profile/worker_jobs.zsh (rev 0)
+++ usertools/worker-profile/worker_jobs.zsh 2011-01-20 15:35:55 UTC (rev 4006)
@@ -0,0 +1,22 @@
+#!/bin/zsh
+
+# Lists worker job counts
+# Uses worker_jobs_lib.zsh
+
+if [[ ${#*} == 0 ]]
+then
+ print "Lists worker job counts"
+ print "usage: worker_jobs.zsh <RESULT> <LOGS>"
+fi
+
+PLOTS=$( dirname $0 )
+TOOLS=${PLOTS}/../tools
+
+source ${TOOLS}/helpers.zsh
+[[ $? != 0 ]] && print "Could not source helpers.zsh!" && exit 1
+
+source ${PLOTS}/worker_jobs_lib.zsh
+
+worker_jobs ${*} > ${RESULT}
+
+return 0
Property changes on: usertools/worker-profile/worker_jobs.zsh
___________________________________________________________________
Name: svn:executable
+ *
Added: usertools/worker-profile/worker_jobs_duration.zsh
===================================================================
--- usertools/worker-profile/worker_jobs_duration.zsh (rev 0)
+++ usertools/worker-profile/worker_jobs_duration.zsh 2011-01-20 15:35:55 UTC (rev 4006)
@@ -0,0 +1,30 @@
+#!/bin/zsh
+
+# Lists worker job counts, sorted for plotting
+# usage: worker_jobs_spectrum.zsh <RESULT> <LOGS>
+# The result is a tabular file compatible with plotter/lines.zsh
+
+if [[ ${#*} == 0 ]]
+then
+ print "Lists worker job counts, sorted for plotting"
+ print "usage: worker_jobs_spectrum.zsh <RESULT> <LOGS>"
+ return 1
+fi
+
+PLOTS=$( dirname $0 )
+TOOLS=${PLOTS}/../tools
+
+source ${TOOLS}/helpers.zsh
+[[ $? != 0 ]] && print "Could not source helpers.zsh!" && exit 1
+
+source ${PLOTS}/worker_jobs_lib.zsh
+
+RESULT=$1
+shift
+LOGS=${*}
+
+# Output: <index> <jobs> <ID> <logfile>
+worker_jobs ${LOGS} | sort -k 2 | nl -w1 | \
+ awk '{ print $1 " " $3 " # " $2 " " $4 }' > ${RESULT}
+
+return 0
Property changes on: usertools/worker-profile/worker_jobs_duration.zsh
___________________________________________________________________
Name: svn:executable
+ *
Added: usertools/worker-profile/worker_jobs_lib.zsh
===================================================================
--- usertools/worker-profile/worker_jobs_lib.zsh (rev 0)
+++ usertools/worker-profile/worker_jobs_lib.zsh 2011-01-20 15:35:55 UTC (rev 4006)
@@ -0,0 +1,23 @@
+
+# Lists worker job counts from all given worker logs
+# Should just require log level INFO
+worker_jobs()
+{
+ if [[ ${#*} == 0 ]]
+ then
+ print "Lists worker job counts"
+ print "usage: worker_jobs.zsh <RESULT> <LOGS>"
+ fi
+
+ RESULT=$1
+ shift
+ LOGS=${*}
+ for LOG in ${LOGS}
+ do
+ ID=$( sed -n '/.*ID.*/{s/.*ID=\(.*\)/\1/;p;q}' ${LOG} )
+ JOBS=$( sed -n '/.*Ran a total.*/{s/.*of \(.*\) jobs/\1/;p;q}' ${LOG} )
+ print ${ID} ${JOBS} ${LOG}
+ done
+
+ return 0
+}
Added: usertools/worker-profile/worker_profile_extract.zsh
===================================================================
--- usertools/worker-profile/worker_profile_extract.zsh (rev 0)
+++ usertools/worker-profile/worker_profile_extract.zsh 2011-01-20 15:35:55 UTC (rev 4006)
@@ -0,0 +1,19 @@
+#!/bin/zsh
+
+# Extract the PROFILE: lines from the end of the worker log
+# Requires you to set $PROFILE=1 in worker.pl
+
+PLOTS=$( dirname $0 )
+TOOLS=${PLOTS}/../tools
+
+source ${TOOLS}/helpers.zsh
+[[ $? != 0 ]] && print "Could not source helpers.zsh!" && exit 1
+
+LOG=$1
+PROFILE=$2
+
+checkvars LOG PROFILE
+
+grep "PROFILE:" ${LOG} | awk '{ print $5 " " $6 " " $7 }' > ${PROFILE}
+
+exit 0
Property changes on: usertools/worker-profile/worker_profile_extract.zsh
___________________________________________________________________
Name: svn:executable
+ *
Added: usertools/worker-profile/worker_profile_util.zsh
===================================================================
--- usertools/worker-profile/worker_profile_util.zsh (rev 0)
+++ usertools/worker-profile/worker_profile_util.zsh 2011-01-20 15:35:55 UTC (rev 4006)
@@ -0,0 +1,95 @@
+#!/bin/zsh
+
+# WORKER PROFILE UTILIZATION
+# Build a data file for plotting from a worker.pl profile log
+# 2-column output format: <time from 0> <load>
+# usage: worker_profile_util.zsh <LOG> <OUTPUT> <GRANULARITY>?
+# Output is compatible with plotter/lines.zsh
+
+LOG=$1
+DATA=$2
+# If given, set the output data time granularity in seconds
+GRANULARITY=${3:-0.1}
+
+PLOTS=$( dirname $0 )
+TOOLS=${PLOTS}/../tools
+
+source ${TOOLS}/helpers.zsh
+[[ $? != 0 ]] && print "Could not source helpers.zsh!" && exit 1
+
+CORES=1
+
+checkvars LOG DATA
+
+PROFILE=${LOG}.ptmp
+
+${PLOTS}/worker_profile_extract.zsh ${LOG} ${PROFILE}
+
+EVENTS=( $( < ${PROFILE} ) )
+
+local -F 3 LOAD=0
+
+local -F 3 TIMESTAMP TIME_PREV USAGE
+local -F 3 START=${EVENTS[3]}
+local -F 3 TIME=${START}
+TIME_PREV=${TIME}
+
+data()
+{
+ local -F 5 T=$1
+ local LOAD=$2
+ local COMMENT=$3
+ print ${T} ${LOAD} ${COMMENT} >> ${DATA}
+}
+
+eventFORK()
+{
+ (( LOAD++ ))
+}
+
+eventTERM()
+{
+ (( LOAD-- ))
+}
+
+eventSTOP()
+{
+ RUNNING=0
+}
+
+# Truncate DATA
+printf "" > ${DATA}
+
+data $(( TIME-START )) ${LOAD}
+
+i=4
+RUNNING=1
+while (( RUNNING ))
+ do
+ EVENT=${EVENTS[i]}
+ PID=${EVENTS[i+1]}
+ TIMESTAMP=${EVENTS[i+2]}
+
+ while (( TIME < TIMESTAMP ))
+ do
+ data $(( TIME-START )) ${LOAD}
+ (( TIME+=GRANULARITY ))
+ done
+
+ USAGE+=$(( (TIMESTAMP-TIME_PREV) * LOAD ))
+ event${EVENT}
+
+ data $(( TIMESTAMP-START )) ${LOAD} "#"
+
+ TIME_PREV=${TIMESTAMP}
+ (( i+=3 ))
+done
+
+typeset -F 3 TOTAL=$(( (TIMESTAMP-START) * CORES ))
+typeset -F 3 UTIL=$(( USAGE/TOTAL ))
+
+print "USAGE: ${USAGE}"
+print "TOTAL: ${TOTAL}"
+print "UTIL: ${UTIL}"
+
+exit 0
Property changes on: usertools/worker-profile/worker_profile_util.zsh
___________________________________________________________________
Name: svn:executable
+ *
More information about the Swift-commit
mailing list