libstore: localize act, builderActivities
only LocalDerivationGoal needs these, and once the child is done running (or is begin torn down) we can just destroy all of them. Change-Id: Id4d9f0105aaf33d6736c435bb891d3f9af8e7894
This commit is contained in:
@@ -134,11 +134,7 @@ Goal::WorkResult DerivationGoal::timedOut(Error && ex)
|
||||
|
||||
kj::Promise<Result<Goal::WorkResult>> DerivationGoal::workImpl() noexcept
|
||||
{
|
||||
KJ_DEFER({
|
||||
act.reset();
|
||||
actLock.reset();
|
||||
builderActivities.clear();
|
||||
});
|
||||
KJ_DEFER({ actLock.reset(); });
|
||||
|
||||
BOOST_OUTCOME_CO_TRY(auto result, co_await (useDerivation ? getDerivation() : haveDerivation()));
|
||||
result.storePath = drvPath;
|
||||
|
||||
@@ -210,15 +210,11 @@ struct DerivationGoal : public Goal
|
||||
|
||||
NotifyingCounter<uint64_t>::Bump mcExpectedBuilds, mcRunningBuilds;
|
||||
|
||||
std::optional<Activity> act;
|
||||
|
||||
/**
|
||||
* Activity that denotes waiting for a lock.
|
||||
*/
|
||||
std::optional<Activity> actLock;
|
||||
|
||||
std::map<ActivityId, Activity> builderActivities;
|
||||
|
||||
/** Witness type to say that the drvPath has already been added as a temp root */
|
||||
struct DrvHasRoot { explicit DrvHasRoot() = default; };
|
||||
|
||||
|
||||
@@ -280,12 +280,6 @@ retry:
|
||||
/* Okay, we have to build. */
|
||||
TRY_AWAIT(startBuilder());
|
||||
|
||||
act = logger->startActivity(
|
||||
lvlInfo,
|
||||
actBuild,
|
||||
buildDescription(),
|
||||
Logger::Fields{worker.store.printStorePath(drvPath), "", 1, 1}
|
||||
);
|
||||
mcRunningBuilds = worker.runningBuilds.addTemporarily(1);
|
||||
if (auto error = TRY_AWAIT(handleChildOutput())) {
|
||||
co_return std::move(*error);
|
||||
@@ -2699,12 +2693,20 @@ try {
|
||||
|
||||
AsyncFdIoStream in(AsyncFdIoStream::shared_fd{}, builderOutPTY.get());
|
||||
|
||||
std::map<ActivityId, Activity> builderActivities;
|
||||
LogLineSplitter splitter;
|
||||
uint64_t logSize = 0;
|
||||
|
||||
auto act = logger->startActivity(
|
||||
lvlInfo,
|
||||
actBuild,
|
||||
buildDescription(),
|
||||
Logger::Fields{worker.store.printStorePath(drvPath), "", 1, 1}
|
||||
);
|
||||
|
||||
auto flushLine = [&](const std::string & line) {
|
||||
if (const auto state =
|
||||
handleJSONLogMessage(line, *act, builderActivities, "the derivation builder"))
|
||||
handleJSONLogMessage(line, act, builderActivities, "the derivation builder"))
|
||||
{
|
||||
return *state;
|
||||
} else {
|
||||
@@ -2713,7 +2715,7 @@ try {
|
||||
logTail.pop_front();
|
||||
}
|
||||
|
||||
return act->result(resBuildLogLine, line);
|
||||
return act.result(resBuildLogLine, line);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2740,7 +2742,7 @@ try {
|
||||
if (data.empty()) {
|
||||
if (auto left = splitter.finish(); !left.empty()) {
|
||||
if (flushLine(left) == Logger::BufferState::NeedsFlush) {
|
||||
TRY_AWAIT(act->getLogger().flush());
|
||||
TRY_AWAIT(act.getLogger().flush());
|
||||
}
|
||||
}
|
||||
co_return std::nullopt;
|
||||
@@ -2758,7 +2760,7 @@ try {
|
||||
while (!data.empty()) {
|
||||
if (auto line = splitter.feed(data)) {
|
||||
if (flushLine(*line) == Logger::BufferState::NeedsFlush) {
|
||||
TRY_AWAIT(act->getLogger().flush());
|
||||
TRY_AWAIT(act.getLogger().flush());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user