Skip to content

Commit 72e1d68

Browse files
Add performance profiling stats (#460)
* Add performance profiling stats * Break lines * Break lines * Switch off by default * [MegaLinter] Apply linters automatic fixes (#22) Co-authored-by: vkucera <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: vkucera <[email protected]>
1 parent b886ad8 commit 72e1d68

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

codeHF/config_tasks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ DOPOSTPROCESS=1 # Run output postprocessing. (Comparison plots. Requires DOA
3131

3232
DATABASE_O2="workflows.yml" # Workflow specification database
3333
MAKE_GRAPH=0 # Make topology graph.
34+
MAKE_PERF_STATS=0 # Produce performance profiling stats.
3435

3536
# Activation of O2 workflows
3637
# Trigger selection
@@ -506,6 +507,7 @@ function MakeScriptO2 {
506507
[ "$DEBUG" -eq 1 ] && OPT_MAKECMD+=" -d"
507508
[ $SAVETREES -eq 1 ] && OPT_MAKECMD+=" -t"
508509
[ $MAKE_GRAPH -eq 1 ] && OPT_MAKECMD+=" -g"
510+
[ $MAKE_PERF_STATS -eq 1 ] && OPT_MAKECMD+=" -p"
509511

510512
# Make a copy of the default workflow database file before modifying it.
511513
DATABASE_O2_EDIT="${DATABASE_O2/.yml/_edit.yml}"

codeJE/config_tasks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ DOPOSTPROCESS=1 # Run output postprocessing. (Comparison plots. Requires DOA
3131

3232
DATABASE_O2="workflows.yml" # Workflow specification database
3333
MAKE_GRAPH=0 # Make topology graph.
34+
MAKE_PERF_STATS=0 # Produce performance profiling stats.
3435

3536
# Activation of O2 workflows
3637
# Table producers
@@ -164,6 +165,7 @@ function MakeScriptO2 {
164165
[ "$DEBUG" -eq 1 ] && OPT_MAKECMD+=" -d"
165166
[ $SAVETREES -eq 1 ] && OPT_MAKECMD+=" -t"
166167
[ $MAKE_GRAPH -eq 1 ] && OPT_MAKECMD+=" -g"
168+
[ $MAKE_PERF_STATS -eq 1 ] && OPT_MAKECMD+=" -p"
167169

168170
# Make a copy of the default workflow database file before modifying it.
169171
DATABASE_O2_EDIT="${DATABASE_O2/.yml/_edit.yml}"

config/config_tasks_dummy.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ DOPOSTPROCESS=1 # Run output postprocessing. (Comparison plots. Requires DOA
3030
[ "$INPUT_IS_O2" -eq 1 ] && { DOCONVERT=0; DOALI=0; }
3131

3232
DATABASE_O2="workflows_dummy.yml" # Workflow specification database
33-
MAKE_GRAPH=0 # Make topology graph.
33+
MAKE_GRAPH=0 # Make topology graph.
34+
MAKE_PERF_STATS=0 # Produce performance profiling stats.
3435

3536
# Activation of O2 workflows
3637
# Trigger selection
@@ -133,6 +134,7 @@ function MakeScriptO2 {
133134
[ "$DEBUG" -eq 1 ] && OPT_MAKECMD+=" -d"
134135
[ $SAVETREES -eq 1 ] && OPT_MAKECMD+=" -t"
135136
[ $MAKE_GRAPH -eq 1 ] && OPT_MAKECMD+=" -g"
137+
[ $MAKE_PERF_STATS -eq 1 ] && OPT_MAKECMD+=" -p"
136138

137139
# Make a copy of the default workflow database file before modifying it.
138140
DATABASE_O2_EDIT="${DATABASE_O2/.yml/_edit.yml}"

exec/make_command_o2.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,15 @@ def main():
146146
parser.add_argument("-t", "--tables", action="store_true", help="save table into trees")
147147
parser.add_argument("-g", "--graph", action="store_true", help="make topology graph")
148148
parser.add_argument("-d", "--debug", action="store_true", help="print debugging info")
149+
parser.add_argument("-p", "--perf", action="store_true", help="produce performance profiling stats")
149150
args = parser.parse_args()
150151
path_file_database = args.database
151152
debug = args.debug
152153
workflows_add = args.workflows.split() if args.workflows else ""
153154
mc_mode = args.mc
154155
save_tables = args.tables
155156
make_graph = args.graph
157+
perf = args.perf
156158

157159
# Open database input file.
158160
if debug:
@@ -171,6 +173,13 @@ def main():
171173
msg_warn("MC mode is on.")
172174
if save_tables:
173175
msg_warn("Tables will be saved in trees.")
176+
if perf:
177+
msg_warn(
178+
"Performance profiling stats will be saved in perf.data files.\n"
179+
" Convert them with: perf script --demangle -i perf.data --no-inline |"
180+
" c++filt -r -t > profile.linux-perf.txt\n"
181+
" and upload the output to https://www.speedscope.app/."
182+
)
174183

175184
# Get workflow-independent options.
176185
dic_opt = dic_in["options"]
@@ -271,6 +280,10 @@ def main():
271280
msg_fatal("Nothing to do!")
272281
# Remove the leading "| \\\n".
273282
command = command[4:]
283+
# Append performance profiling options.
284+
if perf:
285+
opt_perf = "perf record -F 99 -g --call-graph dwarf --user-callchains"
286+
command = command.replace(string_wf, f"{opt_perf} {string_wf}")
274287
# Append global options.
275288
if opt_global:
276289
command += " " + opt_global
@@ -311,4 +324,5 @@ def main():
311324
eprint("Produce graph with Graphviz: dot -T%s %s -o %s" % (ext_graph, path_file_dot, path_file_graph))
312325

313326

314-
main()
327+
if __name__ == "__main__":
328+
main()

0 commit comments

Comments
 (0)