mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-09 23:44:00 +03:00
instrumentation: Add Google trace output
Add a feature to parse snippets into a trace file compatible with the Google Trace Event Format. Fixes: #26674
This commit is contained in:
1 parent
b6dcbc4387
commit
bf52fbfbc4
19 files changed
+489
-70
No files matched your search
@@ -78,7 +78,7 @@ equivalent JSON query file.
|
||||
API_VERSION 1
|
||||
DATA_VERSION 1
|
||||
HOOKS postGenerate preCMakeBuild postCMakeBuild
|
||||
OPTIONS staticSystemInformation dynamicSystemInformation
|
||||
OPTIONS staticSystemInformation dynamicSystemInformation trace
|
||||
CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data.cmake
|
||||
CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data_2.cmake
|
||||
CUSTOM_CONTENT myString STRING string
|
||||
@@ -94,7 +94,7 @@ equivalent JSON query file.
|
||||
"postGenerate", "preCMakeBuild", "postCMakeBuild"
|
||||
],
|
||||
"options": [
|
||||
"staticSystemInformation", "dynamicSystemInformation"
|
||||
"staticSystemInformation", "dynamicSystemInformation", "trace"
|
||||
],
|
||||
"callbacks": [
|
||||
"/path/to/cmake -P /path/to/handle_data.cmake"
|
||||
|
||||
@@ -162,6 +162,12 @@ subdirectories:
|
||||
A subset of the collected data, containing any
|
||||
:ref:`cmake_instrumentation Configure Content` files.
|
||||
|
||||
``data/trace/``
|
||||
A subset of the collected data, containing the `Google Trace File`_ created
|
||||
from the most recent `Indexing`_. Unlike other data files, the most recent
|
||||
trace file remains even after `Indexing`_ occurs and all `Callbacks`_ are
|
||||
executed, until the next time `Indexing`_ occurs.
|
||||
|
||||
``cdash/``
|
||||
Holds temporary files used internally to generate XML content to be submitted
|
||||
to CDash.
|
||||
@@ -231,6 +237,10 @@ key is required, but all other fields are optional.
|
||||
CDash. Equivalent to having the
|
||||
:envvar:`CTEST_USE_VERBOSE_INSTRUMENTATION` environment variable enabled.
|
||||
|
||||
``trace``
|
||||
Enables generation of a `Google Trace File`_ during `Indexing`_ to
|
||||
visualize data from the `v1 Snippet Files <v1 Snippet File_>`_ collected.
|
||||
|
||||
The ``callbacks`` listed will be invoked during the specified hooks
|
||||
*at a minimum*. When there are multiple query files, the ``callbacks``,
|
||||
``hooks`` and ``options`` between them will be merged. Therefore, if any query
|
||||
@@ -258,7 +268,8 @@ Example:
|
||||
"options": [
|
||||
"staticSystemInformation",
|
||||
"dynamicSystemInformation",
|
||||
"cdashSubmit"
|
||||
"cdashSubmit",
|
||||
"trace"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -270,11 +281,12 @@ files created since the previous indexing. The commands
|
||||
``/usr/bin/cmake -P callback.cmake arg index-<timestamp>.json`` will be executed
|
||||
in that order. The index file will contain the ``staticSystemInformation`` data
|
||||
and each snippet file listed in the index will contain the
|
||||
``dynamicSystemInformation`` data. Once both callbacks have completed, the index
|
||||
file and all snippet files listed by it will be deleted from the project build
|
||||
tree. The instrumentation data will be present in the XML files submitted to
|
||||
CDash, but with truncated command strings because ``cdashVerbose`` was not
|
||||
enabled.
|
||||
``dynamicSystemInformation`` data. Additionally, the index file will contain
|
||||
the path to the generated `Google Trace File`_. Once both callbacks have completed,
|
||||
the index file and data files listed by it (including snippet files, but not
|
||||
the trace file) will be deleted from the project build tree. The instrumentation
|
||||
data will be present in the XML files submitted to CDash, but with truncated
|
||||
command strings because ``cdashVerbose`` was not enabled.
|
||||
|
||||
.. _`cmake-instrumentation Data v1`:
|
||||
|
||||
@@ -285,10 +297,10 @@ Data version specifies the contents of the output files generated by the CMake
|
||||
instrumentation API as part of the `Data Collection`_ and `Indexing`_. A new
|
||||
version number will be created whenever previously included data is removed or
|
||||
reformatted such that scripts written to parse this data may become
|
||||
incompatible with the new format. There are two types of data files generated:
|
||||
the `v1 Snippet File`_ and `v1 Index File`_. When using the `API v1`_, these
|
||||
files live in ``<build>/.cmake/instrumentation/v1/data/`` under the project
|
||||
build tree.
|
||||
incompatible with the new format. There are three types of data files generated:
|
||||
the `v1 Snippet File`_, the `v1 Index File`_, and the `Google Trace File`_.
|
||||
When using the `API v1`_, these files live in
|
||||
``<build>/.cmake/instrumentation/v1/data/`` under the project build tree.
|
||||
|
||||
.. _`cmake-instrumentation v1 Snippet File`:
|
||||
|
||||
@@ -460,6 +472,11 @@ occurs and deleted after any user-specified `Callbacks`_ are executed.
|
||||
generated since the previous index file was created. The file paths are
|
||||
relative to ``dataDir``.
|
||||
|
||||
``trace``:
|
||||
Contains the path to the `Google Trace File`_. This includes data from all
|
||||
corresponding ``snippets`` in the index file. The file path is relative to
|
||||
``dataDir``. Only included when enabled by the `v1 Query Files`_.
|
||||
|
||||
``staticSystemInformation``
|
||||
Specifies the static information collected about the host machine
|
||||
CMake is being run from. Only included when enabled by the `v1 Query Files`_.
|
||||
@@ -502,5 +519,49 @@ Example:
|
||||
"ctest-<hash>-<timestamp>.json",
|
||||
"test-<hash>-<timestamp>.json",
|
||||
"test-<hash>-<timestamp>.json",
|
||||
]
|
||||
],
|
||||
"trace": "trace/trace-<timestamp>.json"
|
||||
}
|
||||
|
||||
Google Trace File
|
||||
-----------------
|
||||
|
||||
Trace files follow the `Google Trace Event Format`_. They include data from
|
||||
all `v1 Snippet File`_ listed in the current index file. These files remain
|
||||
in the build tree even after `Indexing`_ occurs and all `Callbacks`_ are
|
||||
executed, until the next time `Indexing`_ occurs.
|
||||
|
||||
Trace files are stored in the ``JSON Array Format``, where each
|
||||
`v1 Snippet File`_ corresponds to a single trace event object. Each trace
|
||||
event contains the following data:
|
||||
|
||||
``name``
|
||||
A descriptive name generated by CMake based on the given snippet data.
|
||||
|
||||
``cat``
|
||||
The ``role`` from the `v1 Snippet File`_.
|
||||
|
||||
``ph``
|
||||
Currently, always ``"X"`` to represent ``Complete Events``.
|
||||
|
||||
``ts``
|
||||
The ``timeStart`` from the `v1 Snippet File`_, converted from milliseconds to
|
||||
microseconds.
|
||||
|
||||
``dur``
|
||||
The ``duration`` from the `v1 Snippet File`_, converted from milliseconds to
|
||||
microseconds.
|
||||
|
||||
``pid``
|
||||
Unused (always zero).
|
||||
|
||||
``tid``
|
||||
An integer ranging from zero to the number of concurrent jobs with which the
|
||||
processes being indexed ran. This is a synthetic ID calculated by CMake
|
||||
based on the ``ts`` and ``dur`` of all snippet files being indexed in
|
||||
order to produce a more useful visualization of the process concurrency.
|
||||
|
||||
``args``
|
||||
Contains all data from the `v1 Snippet File`_ corresponding to this trace event.
|
||||
|
||||
.. _`Google Trace Event Format`: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
|
||||
Reference in new issue
Block a user