Use factored-out BuildResult
serializer
For the record, here is the Nix 2.19 version: https://github.com/NixOS/nix/blob/2.19-maintenance/src/libstore/serve-protocol.cc, which is what we would initially use. It is a more complete version of what Hydra has today except for one thing: it always unconditionally sets the start/stop times. I think that is correct at the other end seems to unconditionally measure them, but just to be extra careful, I reproduced the old behavior of falling back on Hydra's own measurements if `startTime` is 0. The only difference is that the fallback `stopTime` is now measured from after the entire `BuildResult` is transferred over the wire, but I think that should be negligible if it is measurable at all. (And remember, this is fallback case I already suspect is dead code.)
This commit is contained in:
parent
a5d44b60ea
commit
6a54ab24e2
|
@ -286,9 +286,6 @@ static BuildResult performBuild(
|
||||||
counter & nrStepsBuilding
|
counter & nrStepsBuilding
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
BuildResult result;
|
|
||||||
|
|
||||||
conn.to << ServeProto::Command::BuildDerivation << localStore.printStorePath(drvPath);
|
conn.to << ServeProto::Command::BuildDerivation << localStore.printStorePath(drvPath);
|
||||||
writeDerivation(conn.to, localStore, drv);
|
writeDerivation(conn.to, localStore, drv);
|
||||||
conn.to << options.maxSilentTime << options.buildTimeout;
|
conn.to << options.maxSilentTime << options.buildTimeout;
|
||||||
|
@ -301,30 +298,25 @@ static BuildResult performBuild(
|
||||||
}
|
}
|
||||||
conn.to.flush();
|
conn.to.flush();
|
||||||
|
|
||||||
result.startTime = time(0);
|
BuildResult result;
|
||||||
|
|
||||||
|
time_t startTime, stopTime;
|
||||||
|
|
||||||
|
startTime = time(0);
|
||||||
{
|
{
|
||||||
MaintainCount<counter> mc(nrStepsBuilding);
|
MaintainCount<counter> mc(nrStepsBuilding);
|
||||||
result.status = (BuildResult::Status)readInt(conn.from);
|
result = ServeProto::Serialise<BuildResult>::read(localStore, conn);
|
||||||
}
|
}
|
||||||
result.stopTime = time(0);
|
stopTime = time(0);
|
||||||
|
|
||||||
|
if (!result.startTime) {
|
||||||
result.errorMsg = readString(conn.from);
|
// If the builder gave `startTime = 0`, use our measurements
|
||||||
if (GET_PROTOCOL_MINOR(conn.remoteVersion) >= 3) {
|
// instead of the builder's.
|
||||||
result.timesBuilt = readInt(conn.from);
|
//
|
||||||
result.isNonDeterministic = readInt(conn.from);
|
// Note: this represents the duration of a single round, rather
|
||||||
auto start = readInt(conn.from);
|
// than all rounds.
|
||||||
auto stop = readInt(conn.from);
|
result.startTime = startTime;
|
||||||
if (start && start) {
|
result.stopTime = stopTime;
|
||||||
/* Note: this represents the duration of a single
|
|
||||||
round, rather than all rounds. */
|
|
||||||
result.startTime = start;
|
|
||||||
result.stopTime = stop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (GET_PROTOCOL_MINOR(conn.remoteVersion) >= 6) {
|
|
||||||
ServeProto::Serialise<DrvOutputs>::read(localStore, conn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue