Skip to content

Add option to dump profile output to CSV#2836

Merged
milan-tom merged 13 commits intooxcaml:mainfrom
milan-tom:dump-profile-to-csv
Jul 24, 2024
Merged

Add option to dump profile output to CSV#2836
milan-tom merged 13 commits intooxcaml:mainfrom
milan-tom:dump-profile-to-csv

Conversation

@milan-tom
Copy link
Copy Markdown
Contributor

@milan-tom milan-tom commented Jul 23, 2024

Adds a -dump-into-csv command line flag that outputs the profile information in CSV format.

Design choices

The main design choice was concerning whether to store counters as a single CSV field or multiple. In the end, the choice was made to have a single counters field as the number of counters is variable and not all counters apply to every stage. This single field can easily be divided into the constituent individual counters by scripts using these generated CSV files.

Example outputs

-dprofile -dump-into-csv

pass name,time,alloc,top-heap,absolute-top-heap,counters
a.ml,0.065s,54.4MB,8.21MB,11.2MB,
a.ml/parsing,0.001s,1.05MB,0.46MB,3.47MB,
a.ml/parsing/parser,0.001s,1.04MB,0.46MB,3.47MB,
a.ml/typing,0.008s,8.63MB,1.81MB,5.29MB,
a.ml/typing/infer,0.007s,7.70MB,1.12MB,4.60MB,
a.ml/typing/check_sig,,0.38MB,0.69MB,5.29MB,
a.ml/typing/save_cmi,,0.07MB,,,
a.ml/typing/save_cmt,,0.11MB,,,
a.ml/typing/other,,0.35MB,,,
a.ml/transl,0.004s,2.77MB,,,
a.ml/generate,0.052s,42.0MB,5.93MB,11.2MB,
a.ml/generate/flambda2,0.034s,30.2MB,2.72MB,8.02MB,
a.ml/generate/flambda2/lambda_to_flambda,0.002s,1.90MB,,,
a.ml/generate/flambda2/simplify,0.031s,25.5MB,1.45MB,6.74MB,
a.ml/generate/flambda2/simplify/data_flow,0.009s,4.76MB,,,
a.ml/generate/flambda2/simplify/other,0.021s,20.7MB,1.45MB,6.74MB,
a.ml/generate/flambda2/flambda_to_cmm,0.001s,1.28MB,,,
a.ml/generate/flambda2/other,0.001s,1.51MB,1.27MB,8.02MB,
a.ml/generate/compile_phrases,0.008s,9.37MB,1.46MB,9.48MB,
a.ml/generate/compile_phrases/selection,,0.43MB,,,
a.ml/generate/compile_phrases/zero_alloc_checker,,0.10MB,,,
a.ml/generate/compile_phrases/zero_alloc_checker/check zero_alloc,,0.08MB,,,
a.ml/generate/compile_phrases/zero_alloc_checker/other,,0.01MB,,,
a.ml/generate/compile_phrases/comballoc,,0.06MB,,,
a.ml/generate/compile_phrases/cse,,0.12MB,,,
a.ml/generate/compile_phrases/regalloc,0.006s,8.22MB,1.46MB,9.48MB,
a.ml/generate/compile_phrases/regalloc/cfg,0.006s,8.20MB,1.46MB,9.48MB,
a.ml/generate/compile_phrases/regalloc/cfg/cfgize,0.001s,0.87MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfgize/register_preds,,0.02MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfgize/optimizations,,0.56MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfgize/other,,0.28MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_deadcode,,0.31MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.003s,3.16MB,,,[reload = 30; spill = 30]
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split,0.001s,1.13MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/state,,0.56MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/compute_substitutions,,0.06MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/insert_spills,,0.03MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/insert_reloads,,0.02MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/cfg_deadcode,0.001s,0.38MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/split/other,,0.05MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/stack_slots_optimize,,0.21MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc/other,0.001s,1.81MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_validate_description,0.002s,2.63MB,1.46MB,9.48MB,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_simplify,,0.50MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/peephole_optimize_cfg,,0.09MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/cfg_to_linear,,0.16MB,,,
a.ml/generate/compile_phrases/regalloc/cfg/other,,0.42MB,,,
a.ml/generate/compile_phrases/regalloc/other,,0.01MB,,,
a.ml/generate/compile_phrases/emit_fundecl,,0.19MB,,,
a.ml/generate/compile_phrases/emit_fundecl/emit,,0.18MB,,,
a.ml/generate/compile_phrases/emit_fundecl/other,,0.01MB,,,
a.ml/generate/compile_phrases/other,0.001s,0.19MB,,,
a.ml/generate/write_asm,0.001s,0.69MB,,,
a.ml/generate/assemble,0.007s,,,,
a.ml/generate/other,0.002s,1.71MB,1.74MB,11.2MB,
other,0.009s,7.87MB,3.00MB,,

-dcounters -dump-into-csv

pass name,counters
a.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,[reload = 30; spill = 30]

@milan-tom milan-tom requested a review from xclerc July 23, 2024 12:28
@milan-tom milan-tom self-assigned this Jul 23, 2024
@milan-tom milan-tom marked this pull request as draft July 23, 2024 12:40
@milan-tom milan-tom force-pushed the dump-profile-to-csv branch from cc0825f to 6d092db Compare July 23, 2024 12:48
@milan-tom milan-tom marked this pull request as ready for review July 23, 2024 12:49
@milan-tom milan-tom force-pushed the dump-profile-to-csv branch from 6d092db to 8fb8fb2 Compare July 23, 2024 13:31
@milan-tom milan-tom force-pushed the dump-profile-to-csv branch from f09c1a3 to 7d1dd17 Compare July 24, 2024 08:54
@milan-tom milan-tom requested a review from xclerc July 24, 2024 09:14
Copy link
Copy Markdown
Contributor

@xclerc xclerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I you can just confirm / double check that
the output of -dtimings (used alone) is
not changed by this pull request, I think it
can be merged.

@milan-tom
Copy link
Copy Markdown
Contributor Author

gs (used alone) is
not changed by this pull request, I think it
can be merged.

Manually tested comparing output on test file of -dtimings -dgc-timings from before #2786 and after this PR. Both match with just slight variations in timings and memory allocation (expected).

@milan-tom milan-tom merged commit 2e3e478 into oxcaml:main Jul 24, 2024
@milan-tom milan-tom deleted the dump-profile-to-csv branch July 24, 2024 09:49
@milan-tom milan-tom added the profiling Changes to system for profiling the performance of the compiler label Aug 20, 2024
lukemaurer pushed a commit to lukemaurer/flambda-backend that referenced this pull request Oct 23, 2024
* Add -dump-into-csv command line flag

* Implement exporting profile information to CSV

* Don't always print ancestors when outputting to CSV

* Sanitise profile columns before adding to CSV

* Leave empty cells blank in CSV

* Add headers to CSV profile output

* Don't print to stdout if -dump-into-csv selected

* Don't print gc info to stdout either if -dump-into-csv selected

* Make match case explicit

* Avoid implying formatter can only be for file

* Avoid unnecessary use of optional arguments

* Use "pass" rather than "stage"

* Force newline in CSV output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Changes to system for profiling the performance of the compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants