Commit Graph

50 Commits

Author SHA1 Message Date
Brad King
5f889a093c Merge topic 'instrumentation-exit'
236207b81a instrumentation: Fix snippet `result` field
d3add47973 Tests/Instrumentation: Remove unused files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11339
2025-10-28 09:38:52 -04:00
Tyler Yankee
236207b81a instrumentation: Fix snippet result field
Give the actual exit code of the command from the snippet as intended;
currently, this always gives 0 for sub-commands like compile and link,
as well as `ctest`.

For now, the result in build snippets will be `null`.
2025-10-27 15:42:58 -04:00
Martin Duffy
de3cb099a3 instrumentation: Add showOnly to ctest snippets
Fixes: #27269
2025-10-24 11:08:52 -04:00
Martin Duffy
2976742520 instrumentation: Only quote arguments that contain a space 2025-10-24 11:08:39 -04: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
Brad King
ec0cf06316 Merge topic 'instrumentation-always-record-build'
e730008d7e instrumentation: Record build snippets regardless of hooks

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11255
2025-09-30 10:05:02 -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
Brad King
5291c17310 Merge topic 'instrumentation-load-null'
11f67d416a instrumentation: Use null when CPU load is unknown

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11248
2025-09-29 09:23:03 -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
Tyler Yankee
11f67d416a instrumentation: Use null when CPU load is unknown 2025-09-26 10:16:32 -04:00
Brad King
bd80d21c0c Merge topic 'instrumentation-trace-names'
6929baca2f instrumentation: Fix trace event names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11250
2025-09-26 09:37:06 -04:00
Brad King
48957f9e16 Merge topic 'instrumentation-more-snippet-data'
2fdd1e787f instrumentation: Additional data in custom, install and link snippets
3db07b0189 cmInstallScriptHandler: Refactor to store config and path for each command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11241
2025-09-26 09:34:20 -04:00
Brad King
67add75ad7 instrumentation: Load queries for postBuild hook after build is done
We launch a `ctest --wait-and-collect-instrumentation` daemon at the
beginning of a build to implement the `postBuild` hook.  It waits for
the build tool to terminate and then collects instrumentation data.
If the build re-runs `cmake`, the instrumentation `query/generated`
directory may be regenerated.  Previously the daemon loaded the
queries up front, but that races with regeneration during the build.
Delay loading queries until after the build finishes.

This was exposed by intermittent test failures since commit a249e820a8
(instrumentation: Add file lock for build daemon, 2025-08-05), which
added build-time regeneration of the build system to an instrumentation
test case.
2025-09-25 17:42:30 -04:00
Brad King
b7397f2f29 cmInstrumentation: Simplify test for .json file name suffix 2025-09-25 17:37:41 -04:00
Brad King
67ed07af23 cmInstrumentation: De-duplicate query directory paths 2025-09-25 17:37:14 -04:00
Tyler Yankee
6929baca2f instrumentation: Fix trace event names
Amend commit 933176c2d1 (instrumentation: Rename install and custom
trace events, 2025-09-04) to remove the trailing colon for trace events
which have no name suffix.
2025-09-25 13:59:27 -04:00
Martin Duffy
2fdd1e787f instrumentation: Additional data in custom, install and link snippets
- Include `config` in all `install` and `custom` snippets
- Include `target` for `custom` snippets where applicable
- Document and test inclusion of `language` in `link` snippets

Issue: #27244
2025-09-24 16:39:09 -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
933176c2d1 instrumentation: Rename install and custom trace events
Follow the format of other trace events to produce a pretty name for
install events (as the last component of the install script directory)
and a slightly prettier name for custom events (still limited by the
nature of custom targets).
2025-09-04 11:58:40 -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
Tyler Yankee
455944508e instrumentation: Remove ninja-specific references
Amend commit 314440c320 (instrumentation: Run preBuild and postBuild
hooks before and after make, 2025-02-05) to make comments and variables
names in `cmInstrumentation` agnostic to the build system being used.
2025-07-22 10:51:15 -04:00
Tyler Yankee
7dbe092d77 instrumentation: Support preBuild and postBuild hooks on Windows
* Use `uv_disable_stdio_inheritance` to resolve the deadlock between the
parent build system process and `ctest
--wait-and-collect-instrumentation` on Windows.
* Remove Windows gating from preBuild and postBuild indexing and update
tests and documentation accordingly.

Fixes: #26668
2025-07-22 10:51:03 -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
Ben Boeckel
557c44b93e cmStrCat: use character literals where possible
Found and replaced using the `cmstrcat-to-char-literal` rule for
`ast-grep`.
2025-05-15 19:12:04 +02:00
Brad King
deb44bdf73 Merge topic 'instrumentation-snippet-names'
39f365ec3c instrumentation: Unique snippet file names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10491
2025-03-19 09:05:56 -04:00
Martin Duffy
39f365ec3c instrumentation: Unique snippet file names
Updates the hash in snippet file naming to take the ProcessId into account
so that snippets with identical commands don't risk a collision in filename.

Additionally, this adds a `workingDir` to snippet files so that snippets with
identical commands can be more easily differentiated, such as with install
snippets.
2025-03-18 13:23:02 -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
Martin Duffy
4e7b37cad3 instrumentation: Quote command arguments to preserve separation
Fixes: #26702
2025-02-24 13:11:19 -05:00
Zack Galbreath
a6d4a9a2ae ctest: Include cmake instrumentation data in XML files 2025-02-15 06:25:12 -05:00
Martin Duffy
2299b2fcab instrumentation: Add build snippet
Adds a new snippet generation for recording the full time spent waiting for
`ninja` or `make` invocations to finish.
2025-02-11 13:31:28 -05:00
Martin Duffy
32e9d27c88 instrumentation: Remove undocumented binaryDir field from snippets
Removes field from snippet files redundant with the index file's "buildDir"
2025-02-10 17:19:10 -05:00
Martin Duffy
9689155a05 instrumentation: Add Config value to snippet data 2025-02-09 12:29:09 -05:00
Martin Duffy
6598248da7 instrumentation: Avoid busy-wait on postBuild hook 2025-02-06 07:46: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
9d34069ca8 instrumentation: Add targetLabels field to link snippets
Adds a new data field `targetLabels` to link snippets which contains a list of
text labels from the LABELS target property.
2025-01-17 11:07:30 -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