From 852da07b67564f7a9986f0638aac391d334d4afa Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 24 Sep 2024 00:21:16 +0200 Subject: libstore: replace Goal::WaitForSlot with semaphores now that we have an event loop in the worker we can use it and its magical execution suspending properties to replace the slot counts we managed explicitly with semaphores and raii tokens. technically this would not have needed an event loop base to be doable, but it is a whole lot easier to wait for a token to be available if there is a callback mechanism ready for use that doesn't require a whole damn dedicated abstract method in Goal to work, and specific calls to that dedicated method strewn all over the worker implementation Change-Id: I1da7cf386d94e2bbf2dba9b53ff51dbce6a0cff7 --- src/libstore/build/worker.hh | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/libstore/build/worker.hh') diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh index daa612c06..834ecfda3 100644 --- a/src/libstore/build/worker.hh +++ b/src/libstore/build/worker.hh @@ -1,6 +1,7 @@ #pragma once ///@file +#include "async-semaphore.hh" #include "notifying-counter.hh" #include "types.hh" #include "lock.hh" @@ -93,22 +94,6 @@ private: */ WeakGoals awake; - /** - * Goals waiting for a build slot. - */ - WeakGoals wantingToBuild; - - /** - * Number of build slots occupied. This includes local builds but does not - * include substitutions or remote builds via the build hook. - */ - unsigned int nrLocalBuilds; - - /** - * Number of substitution slots occupied. - */ - unsigned int nrSubstitutions; - /** * Maps used to prevent multiple instantiations of a goal for the * same derivation / path. @@ -148,12 +133,6 @@ private: kj::Own> childFinished; - /** - * Put `goal` to sleep until a build slot becomes available (which - * might be right away). - */ - void waitForBuildSlot(GoalPtr goal); - /** * Wake up a goal (i.e., there is something for it to do). */ @@ -170,16 +149,14 @@ private: void removeGoal(GoalPtr goal); /** - * Registers a running child process. `inBuildSlot` means that - * the process counts towards the jobs limit. + * Registers a running child process. */ - void childStarted(GoalPtr goal, kj::Promise> promise, - bool inBuildSlot); + void childStarted(GoalPtr goal, kj::Promise> promise); /** * Unregisters a running child process. */ - void childTerminated(GoalPtr goal, bool inBuildSlot); + void childTerminated(GoalPtr goal); /** * Pass current stats counters to the logger for progress bar updates. @@ -205,6 +182,7 @@ public: Store & store; Store & evalStore; kj::AsyncIoContext & aio; + AsyncSemaphore substitutions, localBuilds; private: kj::TaskSet children; -- cgit v1.2.3