-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathsim_performance_test.sh
More file actions
executable file
·141 lines (105 loc) · 4.86 KB
/
sim_performance_test.sh
File metadata and controls
executable file
·141 lines (105 loc) · 4.86 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# Script performing a standard collection of
# simulation / reco / etc. tasks in order to collect benchmark
# metrics that can be fed into a time-series database for long term monitoring
# In principle we'd like to take O2 from the last nightly
# number of events / take from first argument or default
NEVENTS=${1:-"2"}
# generator / take from second argument or default
GEN=${2:-"pythia8pp"}
# STARTSEED
SEED=1234
# REPETITIONS FOR STATISTICS
REPS=5
# TIMESTAMP TO USE FOR INJECTION INTO DATABASE
TIMEST=`date +%s`
# convert to nanoseconds needed by InfluxDB
TIMEST="${TIMEST}000000000"
METRICFILE=metrics.dat
for ENGINE in TGeant3 TGeant4; do
### an outer loop over all different configurations
### this can include type of engine, central-barrel vs all, etc.
SIMCONFIG="${GEN}_N${NEVENTS}_${ENGINE}"
HOST=`hostname`
# include header information such as tested alidist tag and O2 tag
TAG="conf=${SIMCONFIG},host=${HOST}${ALIDISTCOMMIT:+,alidist=$ALIDISTCOMMIT}${O2COMMIT:+,o2=$O2COMMIT}"
echo "versions,${TAG} alidist=\"${ALIDISTCOMMIT}\",O2=\"${O2COMMIT}\" " >> metrics.dat
# we count some simple indicators for problems
WARNCOUNT=0
ERRORCOUNT=0
EXCEPTIONCOUNT=0
SECONDS=0
### ------ we run the transport simulation
LOGFILE=log_${SIMCONFIG}
SIMPREFIX=o2sim_${SIMCONFIG}
HITSTATFILE=hitstats_${SIMCONFIG}
taskset -c 1 o2-sim-serial -n ${NEVENTS} -e ${ENGINE} --skipModules ZDC -g ${GEN} --seed $SEED -o ${SIMPREFIX} > $LOGFILE 2>&1
### ------ extract number of hits
root -q -b -l ${O2_ROOT}/share/macro/analyzeHits.C\(\"${SIMPREFIX}\"\) > $HITSTATFILE
TRANSPORTTIME=$SECONDS
### ------- extract metrics for simulation
# initialization real time
INITTIME=`grep "Init: Real time" $LOGFILE | awk '//{print $5}'`
# initialization memory
INITMEM=`grep "Init: Memory" $LOGFILE | awk '//{print $5}'`
# get the actual transport runtime
RUNTIME=`grep " Real time" $LOGFILE | grep -v "Init:" | awk '//{print $4}'`
# initialization memory
TOTALMEM=`grep " Memory used" $LOGFILE | grep -v "Init:" | awk '//{print $4}'`
WARN=`grep "\[WARN\]" $LOGFILE | wc | awk '//{print $1}'`
ERR=`grep "\[ERROR\]" $LOGFILE | wc | awk '//{print $1}'`
EXC=`grep "Exce" $LOGFILE | wc | awk '//{print $1}'`
WARNCOUNT=`bc <<< "${WARNCOUNT} + ${WARN}"`
ERRORCOUNT=`bc <<< "${ERRORCOUNT} + ${ERR}"`
EXCEPTIONCOUNT=`bc <<< "${EXCEPTIONCOUNT} + ${EXC}"`
echo "time_sim,${TAG} init=$INITTIME,run=${RUNTIME} " >> metrics.dat
echo "mem_sim,${TAG} init=$INITMEM,run=${TOTALMEM} " >> metrics.dat
### ------ we run the digitization steps
## we record simple walltime and maximal memory used for each detector
SECONDS=0
digi_time_metrics="walltime_digitizer,${TAG} ";
digi_mem_metrics="maxmem_digitizer,${TAG} ";
hit_metrics="hitnumber,${TAG} ";
digi_total_time=0.
digi_total_mem=0.
hits_total=0
for d in TRD ITS EMC TPC MFT MID MCH FDD FV0 FT0 PHS TOF HMP CPV; do
DIGILOGFILE=logdigi_${SIMCONFIG}_${d}
DIGITIMEFILE=timedigi_${SIMCONFIG}_${d}
TIME="#walltime %e" ${O2_ROOT}/share/scripts/monitor-mem.sh /usr/bin/time --output=${DIGITIMEFILE} o2-sim-digitizer-workflow --sims ${SIMPREFIX} -b --onlyDet ${d} --tpc-lanes 1 --configKeyValues "TRDSimParams.digithreads=1" > ${DIGILOGFILE} 2>&1
# parse metrics
maxmem=`awk '/PROCESS MAX MEM/{print $5}' ${DIGILOGFILE}` # in MB
walltime=`grep "#walltime" ${DIGITIMEFILE} | awk '//{print $2}'`
# parse digitizer time which is more accurately representing the algorithmic component
# add value for this detector
digi_time_metrics="${digi_time_metrics}$d=${walltime},"
digi_mem_metrics="${digi_mem_metrics}$d=${maxmem},"
# accumulate
digi_total_time=`bc <<< "${digi_total_time} + ${walltime}"`
digi_total_mem=`bc <<< "${digi_total_mem} + ${maxmem}"`
# analyse messages in log files
WARN=`grep "\[WARN\]" ${DIGILOGFILE} | wc | awk '//{print $1}'`
ERR=`grep "\[ERROR\]" ${DIGILOGFILE} | wc | awk '//{print $1}'`
EXC=`grep "Exce" ${DIGILOGFILE} | wc | awk '//{print $1}'`
WARNCOUNT=`bc <<< "${WARNCOUNT} + ${WARN}"`
ERRORCOUNT=`bc <<< "${ERRORCOUNT} + ${ERR}"`
EXCEPTIONCOUNT=`bc <<< "${EXCEPTIONCOUNT} + ${EXC}"`
# analyse number of hits
HITNUMBER=`grep "${d}" $HITSTATFILE | awk '//{print $2}'`
hit_metrics="${hit_metrics}$d=${HITNUMBER},"
hits_total=`bc <<< "${hits_total} + ${HITNUMBER}"`
done
DIGITTIME=$SECONDS # with this we can calculate fractional contribution
# finish by adding a total field
digi_time_metrics="${digi_time_metrics}total=${digi_total_time} "
digi_mem_metrics="${digi_mem_metrics}total=${digi_total_mem} "
hit_metrics="${hit_metrics}total=${hits_total} "
echo ${digi_time_metrics} >> metrics.dat
echo ${digi_mem_metrics} >> metrics.dat
echo ${hit_metrics} >> metrics.dat
echo "warncount,${TAG} value=${WARNCOUNT} " >> metrics.dat
echo "errorcount,${TAG} value=${ERRORCOUNT} " >> metrics.dat
echo "exceptioncount,${TAG} value=${EXCEPTIONCOUNT} " >> metrics.dat
done # end loop over configurations engines
# remove empty DPL files
find ./ -size 0 -exec rm {} ';'