3 PROG=zpios-profile-pre.sh
6 trap "PROFILE_RDY=1" SIGHUP
18 RUN_REGION_NOISE=${10}
24 zpios_profile_pre_run_cfg() {
25 cat > ${RUN_DIR}/${RUN_ID}/zpios-config-run.sh << EOF
27 # Zpios Profiling Configuration for Run ${RUN_ID}
30 PROFILE_RUN_DIR=${RUN_DIR}/${RUN_ID}
32 PROFILE_RUN_CR_DIR=${RUN_DIR}/${RUN_ID}/create
33 PROFILE_RUN_CR_PID=${RUN_DIR}/${RUN_ID}/create/profile.pid
34 PROFILE_RUN_CR_OPROFILE_LOG=${RUN_DIR}/${RUN_ID}/create/oprofile.txt
35 PROFILE_RUN_CR_PIDS_LOG=${RUN_DIR}/${RUN_ID}/create/pids.txt
36 PROFILE_RUN_CR_PIDS_CSV=${RUN_DIR}/${RUN_ID}/create/pids.csv
37 PROFILE_RUN_CR_DISK_LOG=${RUN_DIR}/${RUN_ID}/create/disk.txt
38 PROFILE_RUN_CR_DISK_CSV=${RUN_DIR}/${RUN_ID}/create/disk.csv
40 PROFILE_RUN_WR_DIR=${RUN_DIR}/${RUN_ID}/write
41 PROFILE_RUN_WR_PID=${RUN_DIR}/${RUN_ID}/write/profile.pid
42 PROFILE_RUN_WR_OPROFILE_LOG=${RUN_DIR}/${RUN_ID}/write/oprofile.txt
43 PROFILE_RUN_WR_PIDS_LOG=${RUN_DIR}/${RUN_ID}/write/pids.txt
44 PROFILE_RUN_WR_PIDS_CSV=${RUN_DIR}/${RUN_ID}/write/pids.csv
45 PROFILE_RUN_WR_DISK_LOG=${RUN_DIR}/${RUN_ID}/write/disk.txt
46 PROFILE_RUN_WR_DISK_CSV=${RUN_DIR}/${RUN_ID}/write/disk.csv
48 PROFILE_RUN_RD_DIR=${RUN_DIR}/${RUN_ID}/read
49 PROFILE_RUN_RD_PID=${RUN_DIR}/${RUN_ID}/read/profile.pid
50 PROFILE_RUN_RD_OPROFILE_LOG=${RUN_DIR}/${RUN_ID}/read/oprofile.txt
51 PROFILE_RUN_RD_PIDS_LOG=${RUN_DIR}/${RUN_ID}/read/pids.txt
52 PROFILE_RUN_RD_PIDS_CSV=${RUN_DIR}/${RUN_ID}/read/pids.csv
53 PROFILE_RUN_RD_DISK_LOG=${RUN_DIR}/${RUN_ID}/read/disk.txt
54 PROFILE_RUN_RD_DISK_CSV=${RUN_DIR}/${RUN_ID}/read/disk.csv
56 PROFILE_RUN_RM_DIR=${RUN_DIR}/${RUN_ID}/remove
57 PROFILE_RUN_RM_PID=${RUN_DIR}/${RUN_ID}/remove/profile.pid
58 PROFILE_RUN_RM_OPROFILE_LOG=${RUN_DIR}/${RUN_ID}/remove/oprofile.txt
59 PROFILE_RUN_RM_PIDS_LOG=${RUN_DIR}/${RUN_ID}/remove/pids.txt
60 PROFILE_RUN_RM_PIDS_CSV=${RUN_DIR}/${RUN_ID}/remove/pids.csv
61 PROFILE_RUN_RM_DISK_LOG=${RUN_DIR}/${RUN_ID}/remove/disk.txt
62 PROFILE_RUN_RM_DISK_CSV=${RUN_DIR}/${RUN_ID}/remove/disk.csv
64 # PROFILE_PIDS_LOG=${RUN_DIR}/${RUN_ID}/pids-summary.csv
65 # PROFILE_DISK_LOG=${RUN_DIR}/${RUN_ID}/disk-summary.csv
69 zpios_profile_pre_run_args() {
70 cat > ${RUN_DIR}/${RUN_ID}/zpios-args.txt << EOF
72 # Zpios Arguments for Run ${RUN_ID}
78 CHUNK_SIZE=${RUN_CHUNK_SIZE}
79 REGION_SIZE=${RUN_REGION_SIZE}
80 THRD_COUNT=${RUN_THRD_COUNT}
81 REGION_COUNT=${RUN_REGION_COUNT}
83 REGION_NOISE=${RUN_REGION_NOISE}
84 CHUNK_NOISE=${RUN_CHUNK_NOISE}
85 THRD_DELAY=${RUN_THRD_DELAY}
91 # Spawn a user defined profiling script to gather additional data
92 zpios_profile_pre_start() {
95 ${PROFILE_USER} ${RUN_PHASE} ${RUN_DIR} ${RUN_ID} &
96 echo "$!" >${PROFILE_PID}
98 # Sleep waiting for profile script to be ready, it will
99 # signal us via SIGHUP when it is ready to start profiling.
100 while [ ${PROFILE_RDY} -eq 0 ]; do
105 zpios_profile_post_proc_start() {
107 if [ -f ${PROFILE_ARC_PROC} ]; then
108 echo 0 >${PROFILE_ARC_PROC}
111 if [ -f ${PROFILE_VDEV_CACHE_PROC} ]; then
112 echo 0 >${PROFILE_VDEV_CACHE_PROC}
116 zpios_profile_pre_oprofile_start() {
117 local OPROFILE_LOG=$1
119 /usr/bin/opcontrol --reset >>${OPROFILE_LOG} 2>&1
120 /usr/bin/opcontrol --start >>${OPROFILE_LOG} 2>&1
123 zpios_profile_pre_create() {
124 mkdir ${PROFILE_RUN_CR_DIR}
125 zpios_profile_pre_start ${PROFILE_RUN_CR_PID}
126 zpios_profile_post_proc_start
127 zpios_profile_pre_oprofile_start ${PROFILE_RUN_CR_OPROFILE_LOG}
130 zpios_profile_pre_write() {
131 mkdir ${PROFILE_RUN_WR_DIR}
132 zpios_profile_pre_start ${PROFILE_RUN_WR_PID}
133 zpios_profile_post_proc_start
134 zpios_profile_pre_oprofile_start ${PROFILE_RUN_WR_OPROFILE_LOG}
137 zpios_profile_pre_read() {
138 mkdir ${PROFILE_RUN_RD_DIR}
139 zpios_profile_pre_start ${PROFILE_RUN_RD_PID}
140 zpios_profile_post_proc_start
141 zpios_profile_pre_oprofile_start ${PROFILE_RUN_CR_RD_LOG}
144 zpios_profile_pre_remove() {
145 mkdir ${PROFILE_RUN_RM_DIR}
146 zpios_profile_pre_start ${PROFILE_RUN_RM_PID}
147 zpios_profile_post_proc_start
148 zpios_profile_pre_oprofile_start ${PROFILE_RUN_RM_OPROFILE_LOG}
151 # Source global zpios test configuration
152 if [ -f ${RUN_DIR}/zpios-config.sh ]; then
153 . ${RUN_DIR}/zpios-config.sh
156 # Source global per-run test configuration
157 if [ -f ${RUN_DIR}/${RUN_ID}/zpios-config-run.sh ]; then
158 . ${RUN_DIR}/${RUN_ID}/zpios-config-run.sh
161 case "${RUN_PHASE}" in
163 mkdir -p ${RUN_DIR}/${RUN_ID}/
164 zpios_profile_pre_run_cfg
165 zpios_profile_pre_run_args
168 zpios_profile_pre_create
171 zpios_profile_pre_write
174 zpios_profile_pre_read
177 zpios_profile_pre_remove
180 echo "Usage: ${PROG} {pre-run|pre-create|pre-write|pre-read|pre-remove}"