-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[InstrProf] Add frontend temporal profiling flag #122385
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3035,6 +3035,38 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. | |
overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported | ||
by the target, or ``single`` otherwise. | ||
|
||
.. option:: -fprofile-generate-temporal | ||
|
||
Enables the temporal profiling extension for IRPGO to improve startup time by | ||
reducing ``.text`` section page faults. To do this, we instrument function | ||
timestamps to measure when each function is called for the first time and use | ||
this data to generate a function order to improve startup. | ||
|
||
The profile is generated as normal. | ||
|
||
.. code-block:: console | ||
|
||
$ clang++ -O2 -fprofile-generate -fprofile-generate-temporal code.cc -o code | ||
$ ./code | ||
$ llvm-profdata merge -o code.profdata yyy/zzz | ||
|
||
Using the resulting profile, we can either generate a function order to pass | ||
to the linker. | ||
|
||
.. code-block:: console | ||
|
||
$ llvm-profdata order code.profdata -o code.orderfile | ||
$ clang++ -O2 -Wl,--symbol-ordering-file=code.orderfile code.cc -o code | ||
|
||
Or it can be passed to the linker directly. | ||
|
||
.. code-block:: console | ||
|
||
$ clang++ -O2 -Wl,--irpgo-profile=code.profdata,--bp-startup-sort=function code.cc -o code | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -fuse-ld=lld for ELF. (Other linkers will unlikely get the feature in the short time) You probably want to mention the Mach-O way as well |
||
|
||
For more information, please read the RFC: | ||
https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068 | ||
|
||
Fine Tuning Profile Collection | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: %clang -### -c -fprofile-generate -fprofile-generate-temporal %s 2>&1 | FileCheck %s | ||
// RUN: %clang -### -c -fcs-profile-generate -fprofile-generate-temporal %s 2>&1 | FileCheck %s | ||
// RUN: not %clang -### -c -fprofile-generate-temporal %s 2>&1 | FileCheck %s --check-prefix=ERR | ||
|
||
// CHECK: "-mllvm" "--pgo-temporal-instrumentation" | ||
|
||
// ERR: '-fprofile-generate-temporal' only allowed with '-fprofile-generate or -fcs-profile-generate' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mild suggestion:
-fgenerate-temporal-profile
or-ftemporal-profile-generate
seems less awkward to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I somewhat agree, but I think it's more important to keep consistent with the other flags. What do others think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. Maybe
-fprofile-temporal-generate
? Puttingtemporal
closer toprofile
seems like an improvement. But I'm fine with leaving things as-is if others feel strongly about it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this option is used together with the primary option -fprofile-generate, the naming consistency is not important. I suggest making it even simpler: -ftemporal-profile