Use the BuildOptions more eagerly
				
					
				
			This commit is contained in:
		| @@ -269,12 +269,6 @@ StorePathSet sendInputs( | |||||||
|     return inputs; |     return inputs; | ||||||
| } | } | ||||||
|  |  | ||||||
| struct BuildOptions { |  | ||||||
|     unsigned int maxSilentTime, buildTimeout, repeats; |  | ||||||
|     size_t maxLogSize; |  | ||||||
|     bool enforceDeterminism; |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| void RemoteResult::updateWithBuildResult(const nix::BuildResult & buildResult) | void RemoteResult::updateWithBuildResult(const nix::BuildResult & buildResult) | ||||||
| { | { | ||||||
|     RemoteResult thisArrow; |     RemoteResult thisArrow; | ||||||
| @@ -337,7 +331,7 @@ BuildResult performBuild( | |||||||
|     Store & localStore, |     Store & localStore, | ||||||
|     StorePath drvPath, |     StorePath drvPath, | ||||||
|     const BasicDerivation & drv, |     const BasicDerivation & drv, | ||||||
|     const BuildOptions & options, |     const State::BuildOptions & options, | ||||||
|     counter & nrStepsBuilding |     counter & nrStepsBuilding | ||||||
| ) | ) | ||||||
| { | { | ||||||
| @@ -472,7 +466,7 @@ void copyPathsFromRemote( | |||||||
|  |  | ||||||
| void State::buildRemote(ref<Store> destStore, | void State::buildRemote(ref<Store> destStore, | ||||||
|     Machine::ptr machine, Step::ptr step, |     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, |     RemoteResult & result, std::shared_ptr<ActiveStep> activeStep, | ||||||
|     std::function<void(StepState)> updateStep, |     std::function<void(StepState)> updateStep, | ||||||
|     NarMemberDatas & narMembers) |     NarMemberDatas & narMembers) | ||||||
| @@ -523,7 +517,7 @@ void State::buildRemote(ref<Store> destStore, | |||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|           handshake(conn, repeats); |           handshake(conn, buildOptions.repeats); | ||||||
|         } catch (EndOfFile & e) { |         } catch (EndOfFile & e) { | ||||||
|             child.pid.wait(); |             child.pid.wait(); | ||||||
|             std::string s = chomp(readFile(result.logFile)); |             std::string s = chomp(readFile(result.logFile)); | ||||||
| @@ -568,13 +562,7 @@ void State::buildRemote(ref<Store> destStore, | |||||||
|             *localStore, |             *localStore, | ||||||
|             step->drvPath, |             step->drvPath, | ||||||
|             BasicDerivation(*step->drv), |             BasicDerivation(*step->drv), | ||||||
|             { |             buildOptions, | ||||||
|               .maxSilentTime = maxSilentTime, |  | ||||||
|               .buildTimeout = buildTimeout, |  | ||||||
|               .repeats = repeats, |  | ||||||
|               .maxLogSize = maxLogSize, |  | ||||||
|               .enforceDeterminism = step->isDeterministic, |  | ||||||
|             }, |  | ||||||
|             nrStepsBuilding |             nrStepsBuilding | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -98,8 +98,10 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, | |||||||
|        it). */ |        it). */ | ||||||
|     BuildID buildId; |     BuildID buildId; | ||||||
|     std::optional<StorePath> buildDrvPath; |     std::optional<StorePath> buildDrvPath; | ||||||
|     unsigned int maxSilentTime, buildTimeout; |     BuildOptions buildOptions; | ||||||
|     unsigned int repeats = step->isDeterministic ? 1 : 0; |     buildOptions.repeats = step->isDeterministic ? 1 : 0; | ||||||
|  |     buildOptions.maxLogSize = maxLogSize; | ||||||
|  |     buildOptions.enforceDeterminism = step->isDeterministic; | ||||||
|  |  | ||||||
|     auto conn(dbPool.get()); |     auto conn(dbPool.get()); | ||||||
|  |  | ||||||
| @@ -134,18 +136,18 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, | |||||||
|             { |             { | ||||||
|                 auto i = jobsetRepeats.find(std::make_pair(build2->projectName, build2->jobsetName)); |                 auto i = jobsetRepeats.find(std::make_pair(build2->projectName, build2->jobsetName)); | ||||||
|                 if (i != jobsetRepeats.end()) |                 if (i != jobsetRepeats.end()) | ||||||
|                     repeats = std::max(repeats, i->second); |                     buildOptions.repeats = std::max(buildOptions.repeats, i->second); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (!build) build = *dependents.begin(); |         if (!build) build = *dependents.begin(); | ||||||
|  |  | ||||||
|         buildId = build->id; |         buildId = build->id; | ||||||
|         buildDrvPath = build->drvPath; |         buildDrvPath = build->drvPath; | ||||||
|         maxSilentTime = build->maxSilentTime; |         buildOptions.maxSilentTime = build->maxSilentTime; | ||||||
|         buildTimeout = build->buildTimeout; |         buildOptions.buildTimeout = build->buildTimeout; | ||||||
|  |  | ||||||
|         printInfo("performing step ‘%s’ %d times on ‘%s’ (needed by build %d and %d others)", |         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) |     if (!buildOneDone) | ||||||
| @@ -206,7 +208,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, | |||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             /* FIXME: referring builds may have conflicting timeouts. */ |             /* 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) { |         } catch (Error & e) { | ||||||
|             if (activeStep->state_.lock()->cancelled) { |             if (activeStep->state_.lock()->cancelled) { | ||||||
|                 printInfo("marking step %d of build %d as cancelled", stepNr, buildId); |                 printInfo("marking step %d of build %d as cancelled", stepNr, buildId); | ||||||
|   | |||||||
| @@ -447,6 +447,12 @@ private: | |||||||
| public: | public: | ||||||
|     State(); |     State(); | ||||||
|  |  | ||||||
|  |     struct BuildOptions { | ||||||
|  |         unsigned int maxSilentTime, buildTimeout, repeats; | ||||||
|  |         size_t maxLogSize; | ||||||
|  |         bool enforceDeterminism; | ||||||
|  |     }; | ||||||
|  |  | ||||||
| private: | private: | ||||||
|  |  | ||||||
|     nix::MaintainCount<counter> startDbUpdate(); |     nix::MaintainCount<counter> startDbUpdate(); | ||||||
| @@ -531,8 +537,7 @@ private: | |||||||
|  |  | ||||||
|     void buildRemote(nix::ref<nix::Store> destStore, |     void buildRemote(nix::ref<nix::Store> destStore, | ||||||
|         Machine::ptr machine, Step::ptr step, |         Machine::ptr machine, Step::ptr step, | ||||||
|         unsigned int maxSilentTime, unsigned int buildTimeout, |         const BuildOptions & buildOptions, | ||||||
|         unsigned int repeats, |  | ||||||
|         RemoteResult & result, std::shared_ptr<ActiveStep> activeStep, |         RemoteResult & result, std::shared_ptr<ActiveStep> activeStep, | ||||||
|         std::function<void(StepState)> updateStep, |         std::function<void(StepState)> updateStep, | ||||||
|         NarMemberDatas & narMembers); |         NarMemberDatas & narMembers); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user