38 Commits
Author SHA1 Message Date
Martin Duffy 5f222e8f3a Instrumentation: Add Process Resource Usage Metrics
Issue: #26675, #27742
2026-08-27 10:24:25 -04:00
Brad King 8d0615d579 Merge branch 'backport-trace-ninja-dashc' into trace-ninja-dashc 2026-07-09 09:48:43 -04:00
Tyler Yankee 727522d835 instrumentation: Fully resolve compile trace path
When the build is invoked under the native build tool's (commonly
spelled) `-C` option to change from the current working directory to a
given build tree, the default path to a snippet's `-ftime-trace` file
under its corresponding target's object directory was incorrectly
stored based on the path from the working directory.
2026-07-09 09:43:18 -04:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
2026-07-01 14:44:11 -04:00
Daksh Mamodiya bda67b82e7 instrumentation: Write cmakeBuild snippet when build is interrupted
The overall `cmakeBuild` snippet is written only after the native build
tool returns, so interrupting `cmake --build` with Ctrl+C terminated CMake
before it was recorded and lost the build's delineation.

When instrumentation is active, install a scoped, async-signal-safe handler
(POSIX SIGINT; Windows CTRL_C/CTRL_BREAK) that just flags the interrupt. The
existing write then runs during unwind, records the interrupting signal in a
new `interruptSignal` field, skips the post-build index hook, and re-raises so
the exit status still reflects the signal.

The handler lives in its own translation unit, keeping the platform-divergent
signal code out of the main instrumentation implementation.

Issue: #27859
2026-06-18 15:38:43 +02:00
Martin Duffy 0480222ff4 instrumentation: Add compileTrace option
Adds support for optionally saving and reporting trace files generated by
Clang's `-ftime-trace` option.
2026-06-10 15:19:41 -04:00
Martin Duffy 1a85245496 instrumentation: Optionally Record Command Output
Add `stdout`  and `stderr` reporting to instrumentation for `compile`, `link`,
`custom`, `install` and `test` snippets when the `captureOutput` option is
enabled.

Fixes: #26704
2026-06-04 10:42:04 -04:00
Martin Duffy dcf146c34d instrumentation: Revise Data Version format
Give data version the new format <major>.<minor>, so that
the version can be incremented with the introduction of new
features without bumping the major version.

Add support for loading instrumentation JSON queries of unknown
data versions without error.

Issue: #27833
2026-06-02 08:55:20 -04:00
Martin Duffy 0c2fcaec5d instrumentation: Avoid duplicate entries on concurrent indexing
When indexing occurs twice at exactly the same time, there was a possibility
for snippets to show up in more than one index file, and therefore to be
removed by one indexing process while another indexing process ran a user
callback which needed to read the file.

Add a file locking mechanism around indexing to prevent it from happening
concurrently within a project build tree.

Fixes: #27741
2026-04-10 14:06:38 -04:00
Martin DuffyandTyler Yankee fb541168f0 instrumentation: Reset queries on repeat configure steps from CMake GUI
Prevent repeat configure calls from the CMake GUI or `ccmake` tool from
loading query duplicates, which caused many duplicate callbacks to be
invoked on each subsequent hook.

Also ensure that multiple subsequent configure steps invoked by CMake
GUI and `ccmake` each have an associated snippet file during generate.

Fixes: #27651
Co-Authored-By: Tyler Yankee <tyler.yankee@kitware.com>
2026-03-04 16:22:47 -05:00
Martin Duffy 71fe659641 instrumentation: Write empty JSON object when custom content is empty
Replaces the previous value of `null` when no `CUSTOM_CONTENT` was specified.
2026-01-22 13:20:12 -05:00
Martin Duffy 97adbc91fa instrumentation: Move target data into content files
Create a single place to store target data to prevent duplication.
This moves `targetType` and `targetLabels` out of the snippet files
and into a target map in the `cmakeContent` file referenced by each
snippet.

Fixes: #27244
2025-10-02 09:28:20 -04:00
Brad King 35d3fb0e49 Merge topic 'instrumentation-trace-efficient'
f029bd04bf instrumentation: Write trace file incrementally
0882a37f73 instrumentation: Load snippets individually for trace
a31e781fe8 instrumentation: Use end time for snippet file names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11249
2025-10-01 08:40:43 -04:00
Tyler Yankee f029bd04bf instrumentation: Write trace file incrementally
Periodically clearing the output stream buffer saves on memory usage
for large traces.
2025-09-30 10:00:39 -04:00
Tyler Yankee 0882a37f73 instrumentation: Load snippets individually for trace
Only loading the necessary timing data and deferring the dump of all
snippet data into the trace file saves on memory for large traces.
2025-09-30 10:00:37 -04:00
Martin Duffy e730008d7e instrumentation: Record build snippets regardless of hooks 2025-09-26 15:55:08 -04:00
Tyler Yankee a31e781fe8 instrumentation: Use end time for snippet file names 2025-09-26 11:44:00 -04:00
Martin Duffy ba3c278da2 instrumentation: Don't remove content files older than an index
Prevent callbacks from referencing deleted content files by holding onto them
if any index files exist that may contain a reference.
2025-09-19 11:29:16 -04:00
Martin Duffy 4683db44a1 instrumentation: Write index files to data/index/ subdirectory 2025-09-19 11:29:03 -04:00
Tyler Yankee bf52fbfbc4 instrumentation: Add Google trace output
Add a feature to parse snippets into a trace file compatible with the
Google Trace Event Format.

Fixes: #26674
2025-09-03 15:24:10 -04:00
Martin Duffy e6b37105ba instrumentation: Collect custom content from CMake configure
Add a `CUSTOM_CONTENT` argument to `cmake_instrumentation()` for collecting
custom content from configure time.

Snippet files include a reference to a JSON file containing any `CUSTOM_CONTENT`
that was added by this command.

Fixes: #26703
2025-08-21 07:20:12 -04:00
Martin Duffy a249e820a8 instrumentation: Add file lock for build daemon
Prevent starting instrumentation build daemon and related hooks if one is
already running, and when during `cmake --build`.
2025-08-06 11:45:40 -04:00
Martin Duffy 9dec460c8c instrumentation: Store CDash settings in query files
Adds new `cdashSubmit` and `cdashVerbose` options to allow enabling
instrumentation in CDash submissions using query files or the
`cmake_instrumentation` command.

Fixes: #26783, #26727
2025-07-14 15:44:52 -04:00
Martin Duffy afa94bae1e instrumentation: Rename queries field to options
Fixes: #26728
2025-07-10 16:25:07 -04:00
Brad King ed8513783c Merge topic 'instrumentation-fix'
e01d12c14f instrumentation: Prevent unnecessary query loading
f26f127183 instrumentation: Reuse single cmsys::SystemInformation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10863
2025-06-10 09:48:17 -04:00
Martin Duffy e01d12c14f instrumentation: Prevent unnecessary query loading
Don't load queries from instrumentation directories when GetIsInTryCompile
or before ClearGeneratedQueries from previous configures has run.
2025-06-09 11:33:24 -04:00
Martin Duffy f26f127183 instrumentation: Reuse single cmsys::SystemInformation 2025-06-09 11:33:18 -04:00
Brad King 2604f5d8b3 Merge topic 'json-errors-filename'
f134468a98 JSON: Improve JSON error message formatting

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10463
2025-03-14 12:17:02 -04:00
Martin Duffy f134468a98 JSON: Improve JSON error message formatting
This improves the output of JSON-related error messages. It adds the filename to
the output and excludes the column number.

This is particularly useful when there are multiple JSON files being read that
could be responsible for an error, ie CMakePresets.json and
CMakeUserPresets.json, or multiple instrumentation queries.

Issue: #26717
2025-03-13 10:44:31 -04:00
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Kitware Robot de273b2e11 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 09:56:07 -05:00
Zack Galbreath a6d4a9a2ae ctest: Include cmake instrumentation data in XML files 2025-02-15 06:25:12 -05:00
Martin Duffy 9689155a05 instrumentation: Add Config value to snippet data 2025-02-09 12:29:09 -05:00
Martin Duffy 2680f30caf instrumentation: Allow multiple CALLBACK arguments
Don't require quotes around CALLBACK argument and allow it to be passed
multiple times.
2025-02-04 11:15:20 -05:00
Martin Duffy fc1d55f6a5 instrumentation: Add preBuild and postBuild hooks for ninja
Allows instrumentation indexing and callbacks to occur at the start or end of
every `ninja` invocation.
2025-02-04 11:15:11 -05:00
Martin Duffy f62a4ab2ee instrumentation: Refactor cmInstrumentation constructor and usage
Creates a global cmInstrumentation pointer on the CMake Instance to
prevent creating multiple instrumentation objects.
2025-02-03 10:10:06 -05:00
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Martin Duffy 097d4fd1b5 instrumentation: Collect and record project build system metrics
Add a feature for collecting build instrumentation for CMake projects.

Issue: #26099
2025-01-15 09:16:50 -05:00