aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-09-24 00:21:16 +0200
committereldritch horrors <pennae@lix.systems>2024-09-27 16:40:27 +0200
commit852da07b67564f7a9986f0638aac391d334d4afa (patch)
tree993d896dd8353a664723206c2f3ea59230f3d1f5 /src/libstore/build/worker.hh
parentbf32085d63ccfa8fb1e0cff2f2ae7156b4679015 (diff)
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
Diffstat (limited to 'src/libstore/build/worker.hh')
-rw-r--r--src/libstore/build/worker.hh32
1 files changed, 5 insertions, 27 deletions
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"
@@ -94,22 +95,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.
*/
@@ -149,12 +134,6 @@ private:
kj::Own<kj::PromiseFulfiller<void>> 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).
*/
void wakeUp(GoalPtr goal);
@@ -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<Result<Goal::WorkResult>> promise,
- bool inBuildSlot);
+ void childStarted(GoalPtr goal, kj::Promise<Result<Goal::WorkResult>> 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;