Skip to content

Commit

Permalink
Use the BuildOptions more eagerly
Browse files Browse the repository at this point in the history
  • Loading branch information
thufschmitt committed Mar 21, 2022
1 parent 6303d8b commit 5a7d176
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
20 changes: 4 additions & 16 deletions src/hydra-queue-runner/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,6 @@ StorePathSet sendInputs(
return inputs;
}

struct BuildOptions {
unsigned int maxSilentTime, buildTimeout, repeats;
size_t maxLogSize;
bool enforceDeterminism;
};

void RemoteResult::updateWithBuildResult(const nix::BuildResult & buildResult)
{
RemoteResult thisArrow;
Expand Down Expand Up @@ -337,7 +331,7 @@ BuildResult performBuild(
Store & localStore,
StorePath drvPath,
const BasicDerivation & drv,
const BuildOptions & options,
const State::BuildOptions & options,
counter & nrStepsBuilding
)
{
Expand Down Expand Up @@ -472,7 +466,7 @@ void copyPathsFromRemote(

void State::buildRemote(ref<Store> destStore,
Machine::ptr machine, Step::ptr step,
unsigned int maxSilentTime, unsigned int buildTimeout, unsigned int repeats,
const BuildOptions & buildOptions,
RemoteResult & result, std::shared_ptr<ActiveStep> activeStep,
std::function<void(StepState)> updateStep,
NarMemberDatas & narMembers)
Expand Down Expand Up @@ -523,7 +517,7 @@ void State::buildRemote(ref<Store> destStore,
});

try {
handshake(conn, repeats);
handshake(conn, buildOptions.repeats);
} catch (EndOfFile & e) {
child.pid.wait();
string s = chomp(readFile(result.logFile));
Expand Down Expand Up @@ -567,13 +561,7 @@ void State::buildRemote(ref<Store> destStore,
*localStore,
step->drvPath,
BasicDerivation(*step->drv),
{
.maxSilentTime = maxSilentTime,
.buildTimeout = buildTimeout,
.repeats = repeats,
.maxLogSize = maxLogSize,
.enforceDeterminism = step->isDeterministic,
},
buildOptions,
nrStepsBuilding
);

Expand Down
16 changes: 9 additions & 7 deletions src/hydra-queue-runner/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
it). */
BuildID buildId;
std::optional<StorePath> buildDrvPath;
unsigned int maxSilentTime, buildTimeout;
unsigned int repeats = step->isDeterministic ? 1 : 0;
BuildOptions buildOptions;
buildOptions.repeats = step->isDeterministic ? 1 : 0;
buildOptions.maxLogSize = maxLogSize;
buildOptions.enforceDeterminism = step->isDeterministic;

auto conn(dbPool.get());

Expand Down Expand Up @@ -134,18 +136,18 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
{
auto i = jobsetRepeats.find(std::make_pair(build2->projectName, build2->jobsetName));
if (i != jobsetRepeats.end())
repeats = std::max(repeats, i->second);
buildOptions.repeats = std::max(buildOptions.repeats, i->second);
}
}
if (!build) build = *dependents.begin();

buildId = build->id;
buildDrvPath = build->drvPath;
maxSilentTime = build->maxSilentTime;
buildTimeout = build->buildTimeout;
buildOptions.maxSilentTime = build->maxSilentTime;
buildOptions.buildTimeout = build->buildTimeout;

printInfo("performing step ‘%s’ %d times on ‘%s’ (needed by build %d and %d others)",
localStore->printStorePath(step->drvPath), repeats + 1, machine->sshName, buildId, (dependents.size() - 1));
localStore->printStorePath(step->drvPath), buildOptions.repeats + 1, machine->sshName, buildId, (dependents.size() - 1));
}

if (!buildOneDone)
Expand Down Expand Up @@ -206,7 +208,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,

try {
/* FIXME: referring builds may have conflicting timeouts. */
buildRemote(destStore, machine, step, maxSilentTime, buildTimeout, repeats, result, activeStep, updateStep, narMembers);
buildRemote(destStore, machine, step, buildOptions, result, activeStep, updateStep, narMembers);
} catch (Error & e) {
if (activeStep->state_.lock()->cancelled) {
printInfo("marking step %d of build %d as cancelled", stepNr, buildId);
Expand Down
9 changes: 7 additions & 2 deletions src/hydra-queue-runner/state.hh
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ private:
public:
State();

struct BuildOptions {
unsigned int maxSilentTime, buildTimeout, repeats;
size_t maxLogSize;
bool enforceDeterminism;
};

private:

nix::MaintainCount<counter> startDbUpdate();
Expand Down Expand Up @@ -531,8 +537,7 @@ private:

void buildRemote(nix::ref<nix::Store> destStore,
Machine::ptr machine, Step::ptr step,
unsigned int maxSilentTime, unsigned int buildTimeout,
unsigned int repeats,
const BuildOptions & buildOptions,
RemoteResult & result, std::shared_ptr<ActiveStep> activeStep,
std::function<void(StepState)> updateStep,
NarMemberDatas & narMembers);
Expand Down

0 comments on commit 5a7d176

Please sign in to comment.