summaryrefslogtreecommitdiffstats
path: root/docs/UsersManual.rst
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-07-20 23:32:50 +0000
committerXinliang David Li <davidxl@google.com>2016-07-20 23:32:50 +0000
commitde158856500048172bcae540fcfc714cccb63abf (patch)
tree12fb84a4ac630f49e36c24742d6c8f4e8afb213e /docs/UsersManual.rst
parent7715eac013edd50050043611f8e4266f7a214c7e (diff)
[Profile] Document new profile file name modifiers
Differential Revision: http://reviews.llvm.org/D22593 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276207 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/UsersManual.rst')
-rw-r--r--docs/UsersManual.rst36
1 files changed, 34 insertions, 2 deletions
diff --git a/docs/UsersManual.rst b/docs/UsersManual.rst
index 8e591518d5..77d77cc11f 100644
--- a/docs/UsersManual.rst
+++ b/docs/UsersManual.rst
@@ -1470,8 +1470,13 @@ instrumentation:
2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
- in the current directory. You can override that default by setting the
- ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+ in the current directory. You can override that default by using option
+ ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE``
+ environment variable to specify an alternate file. If non-default file name
+ is specified by both the environment variable and the command line option,
+ the environment variable takes precedence. The file name pattern specified
+ can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
@@ -1480,6 +1485,33 @@ instrumentation:
$ LLVM_PROFILE_FILE="code-%p.profraw" ./code
+ The modifier ``%h`` can be used in scenarios where the same instrumented
+ binary is run in multiple different host machines dumping profile data
+ to a shared network based storage. The ``%h`` specifier will be substituted
+ with the hostname so that profiles collected from different hosts do not
+ clobber each other.
+
+ While the use of ``%p`` specifier can reduce the likelihood for the profiles
+ dumped from different processes to clobber each other, such clobbering can still
+ happen because of the ``pid`` re-use by the OS. Another side-effect of using
+ ``%p`` is that the storage requirement for raw profile data files is greatly
+ increased. To avoid issues like this, the ``%m`` specifier can used in the profile
+ name. When this specifier is used, the profiler runtime will substitute ``%m``
+ with a unique integer identifier associated with the instrumented binary. Additionally,
+ multiple raw profiles dumped from different processes that share a file system (can be
+ on different hosts) will be automatically merged by the profiler runtime during the
+ dumping. If the program links in multiple instrumented shared libraries, each library
+ will dump the profile data into its own profile data file (with its unique integer
+ id embedded in the profile name). Note that the merging enabled by ``%m`` is for raw
+ profile data generated by profiler runtime. The resulting merged "raw" profile data
+ file still needs to be converted to a different format expected by the compiler (
+ see step 3 below).
+
+ .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.