Skip to content

instrumentation: Collect and record project instrumentation metrics

Martin Duffy requested to merge martin.duffy/cmake:instrumentation into master

Work in progress changes to address #26099

See these example scripts to test this feature on an existing CMake project.

For testing, this is the current expected query format (lives in <CMAKE_CONFIG_DIR>/timing/v1/query/*.json or <CMAKE_BINARY_DIR>/timing/v1/query/*.json:

{
  "queries": [ // optional, will still gather basic timing + target data if absent
    "staticSystemInformation", // gathers static system info in index files
    "dynamicSystemInformation" // gathers dynamic system info before/after each command
  ],
  "hooks": [ // optional, runs indexing and callbacks automatically at given intervals
    "preConfigure", "postGenerate", "preCMakeBuild", "postCMakeBuild", "postTest", "postInstall"
  ],
  "callbacks": [ // optional, callbacks to run after indexing
    "/path/to/my/script" // executes as "/path/to/my/script /full/path/to/index-<timestamp>-<hash>.json"
  ]
}

Here is what the example output would look like for one compile command

{
  "version": 1,
  "command" : "/usr/bin/c++ -MD -MT CMakeFiles/main.dir/main.cxx.o -MF CMakeFiles/main.dir/main.cxx.o.d -o CMakeFiles/main.dir/main.cxx.o -c <src>/main.cxx",
  "role" : "compile",
  "result" : 1,
  "target": "main",
  "language" : "C++",
  "outputs" : [ "CMakeFiles/main.dir/main.cxx.o" ],
  "outputSizes" : [ 0 ],
  "source" : "<src>/main.cxx",
  "labels": [],
  "dynamicSystemInformation" :
  {
    "afterCPULoadAverage" : 2.3500000000000001,
    "afterHostMemoryUsed" : 6635680.0
    "beforeCPULoadAverage" : 2.3500000000000001,
    "beforeHostMemoryUsed" : 6635832.0
  },
  "timeStart" : 31997009,
  "duration" : 56
}

Not included in this initial merge request

  1. Hooks before/after invocations of the build tool (make or ninja). There is significant complexity around implementing this so I will include it in a following MR.

  2. Ability to submit data to CDash @zackgalbreath is working on this and will open a followup once this work is merged.

The documentation in this MR includes only the functionality currently included, so it excludes both of these.

Edited by Martin Duffy

Merge request reports

Loading