Skip to content

Add scripts to combine profile information for all files in compiler#2846

Merged
milan-tom merged 20 commits intooxcaml:mainfrom
milan-tom:profile-information-collection-scripts
Jul 30, 2024
Merged

Add scripts to combine profile information for all files in compiler#2846
milan-tom merged 20 commits intooxcaml:mainfrom
milan-tom:profile-information-collection-scripts

Conversation

@milan-tom
Copy link
Copy Markdown
Contributor

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

Running ./scripts/generate-profile-csvs.sh builds the whole compiler, exporting CSV files containing the profile information for each file and combines these combines these CSV files to produce summary.csv containing data for the relevant passes. For example:

pass name,time,reload,spill
,s,,
ocaml/stdlib/camlinternalAtomic.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/camlinternalFormatBasics.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.002,22,22
ocaml/stdlib/stdlib.pp.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.010,94,85
ocaml/stdlib/std_exit.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/atomic.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/mutex.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,6,5
ocaml/stdlib/unit.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/bool.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/camlinternalComprehension.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,8,8
ocaml/stdlib/int.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/either.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,0,0
ocaml/stdlib/char.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,2,2
ocaml/stdlib/sys.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,4,4
ocaml/stdlib/condition.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/int64.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,1,1
ocaml/stdlib/semaphore.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,16,12
ocaml/stdlib/uchar.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,6,6
ocaml/stdlib/int32.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,1,1
ocaml/stdlib/nativeint.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.001,1,1
ocaml/stdlib/obj.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,0.002,0,0
ocaml/stdlib/callback.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
ocaml/stdlib/type.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,,0,0
...
ocaml/parser.pp.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,00.794,7392,5995
ocaml/pprintast.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,00.179,1437,1278
ocaml/tools/ocamlmktop.exe/regalloc/cfg/cfg_irc,0.044,317,298
ocaml/main_native.exe/regalloc/cfg/cfg_irc,0.044,317,298
ocaml/tools/ocamldep.exe/regalloc/cfg/cfg_irc,0.043,317,298
ocaml/tools/ocamlmklib.exe/regalloc/cfg/cfg_irc,0.044,317,298
tools/flambda_backend_objinfo.exe/regalloc/cfg/cfg_irc,0.103,933,778
tools/merge_archives.exe/regalloc/cfg/cfg_irc,0.101,933,778
tools/generate_cached_generic_functions.exe/regalloc/cfg/cfg_irc,0.102,933,778
flambda_backend_main_native.exe/regalloc/cfg/cfg_irc,0.182,1842,1584
ocaml/otherlibs/dynlink/pprintast.ml/generate/compile_phrases/regalloc/cfg/cfg_irc,00.174,1437,1278
ocaml/ocamldoc/odoc_native.exe/regalloc/cfg/cfg_irc,0.044,320,300
native_toplevel/opttopstart.exe/regalloc/cfg/cfg_irc,0.182,1842,1584

The second column contains the units for each field (can use header=[0,1] in pandas.read_csv).

@milan-tom milan-tom changed the title Profile information collection scripts Add scripts to combine profile information for all files in compiler Jul 24, 2024
@milan-tom milan-tom requested a review from xclerc July 24, 2024 16:59
@milan-tom milan-tom marked this pull request as draft July 25, 2024 08:44
@milan-tom milan-tom marked this pull request as ready for review July 25, 2024 10:17
@milan-tom milan-tom force-pushed the profile-information-collection-scripts branch from fd11812 to 34bb36f Compare July 25, 2024 14:02
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.

(A first pass - need to read the Python script again.)

@milan-tom milan-tom force-pushed the profile-information-collection-scripts branch 2 times, most recently from 6161f31 to 235c764 Compare July 26, 2024 14:55
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.

A couple of comments about the
Python script - since it is an
auxiliary script, it is OK to cut
corners if something is long or
difficult to implement.

@milan-tom milan-tom requested a review from xclerc July 30, 2024 08:54
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.

As discussed off-line, I think the current
state is OK, but feel free to delay merge
if you want to tweak the logic of the
bash script and/or want to have a second
reviewer.

@milan-tom milan-tom force-pushed the profile-information-collection-scripts branch from 6bcc3f1 to a0999c1 Compare July 30, 2024 12:12
@milan-tom milan-tom merged commit ac9b571 into oxcaml:main Jul 30, 2024
@milan-tom milan-tom deleted the profile-information-collection-scripts branch July 30, 2024 13:01
@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
…iles in compiler (oxcaml#2846)

* Fix printing still happening even if -dump-into-csv set

* Dirty fix to avoid outputting profile information when using make install to dump CSVs for whole compiler

* Add scripts to combine profile information for all compiler files

* Automatically detect summary field names from CSV files

* Make output argument clearer

* Remove total aggregation (leave to end user)

* Support displaying data for multiple passes per file (when they both contain counter data)

* Fix pass name prefix sanitisation issue for CSV

* Move units to second header of summary CSV

* Clean up

* Rename script

* Add use case to hack comment

* Inline script to build compiler

* Fix Python file docstring

* Use _profile as dump directory to convey idea of artifacts being generated

* Simplify OCAMLPARAM using oxcaml#2855

* Move removal completely to script and remove before (with additional checks)

* Remove redundant reverting of environment variables

* Clean up

* Remove unnecessary hack from ocaml/driver/optmaindriver.ml
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