1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

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.
This commit is contained in:
Brad King
2025-09-25 17:06:55 -04:00
parent b7397f2f29
commit 67add75ad7
2 changed files with 3 additions and 3 deletions

View File

@@ -790,7 +790,7 @@ int cmInstrumentation::CollectTimingAfterBuild(int ppid)
};
int ret = this->InstrumentCommand(
"build", {}, [waitForBuild]() { return waitForBuild(); }, cm::nullopt,
cm::nullopt, LoadQueriesAfter::No);
cm::nullopt, LoadQueriesAfter::Yes);
this->CollectTimingData(cmInstrumentationQuery::Hook::PostBuild);
return ret;
}

View File

@@ -194,8 +194,8 @@ int main(int argc, char const* const* argv)
// Dispatch 'ctest --collect-instrumentation' once given PID finishes
if (argc == 4 &&
strcmp(argv[1], "--wait-and-collect-instrumentation") == 0) {
return cmInstrumentation(argv[2]).CollectTimingAfterBuild(
std::stoi(argv[3]));
return cmInstrumentation(argv[2], cmInstrumentation::LoadQueriesAfter::No)
.CollectTimingAfterBuild(std::stoi(argv[3]));
}
// Dispatch 'ctest --collect-instrumentation' mode directly.