libstore: asyncify Realisation::closure

Change-Id: I8ed52455bea0e166098de9c77d55a2f843530d64
This commit is contained in:
eldritch horrors
2025-02-25 02:09:22 +00:00
parent c566a69e79
commit 42a8fb9656
5 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -1204,7 +1204,7 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
TRY_AWAIT(next->computeFSClosure(newPaths, closure));
for (auto & path : closure)
goal.addDependency(path);
for (auto & real : Realisation::closure(*next, newRealisations))
for (auto & real : TRY_AWAIT(Realisation::closure(*next, newRealisations)))
goal.addedDrvOutputs.insert(real.id);
co_return results;
+3 -3
View File
@@ -453,9 +453,9 @@ try {
auto info = store.queryPathInfo(outputPath);
co_return TRY_AWAIT(
drvOutputReferences(Realisation::closure(store, inputRealisations), info->references)
);
co_return TRY_AWAIT(drvOutputReferences(
TRY_AWAIT(Realisation::closure(store, inputRealisations)), info->references
));
} catch (...) {
co_return result::current_exception();
}
+14 -6
View File
@@ -23,15 +23,20 @@ std::string DrvOutput::to_string() const {
return strHash() + "!" + outputName;
}
std::set<Realisation> Realisation::closure(Store & store, const std::set<Realisation> & startOutputs)
{
kj::Promise<Result<std::set<Realisation>>>
Realisation::closure(Store & store, const std::set<Realisation> & startOutputs)
try {
std::set<Realisation> res;
Realisation::closure(store, startOutputs, res);
return res;
TRY_AWAIT(Realisation::closure(store, startOutputs, res));
co_return res;
} catch (...) {
co_return result::current_exception();
}
void Realisation::closure(Store & store, const std::set<Realisation> & startOutputs, std::set<Realisation> & res)
{
kj::Promise<Result<void>> Realisation::closure(
Store & store, const std::set<Realisation> & startOutputs, std::set<Realisation> & res
)
try {
auto getDeps = [&](const Realisation& current) -> std::set<Realisation> {
std::set<Realisation> res;
for (auto& [currentDep, _] : current.dependentRealisations) {
@@ -45,6 +50,9 @@ void Realisation::closure(Store & store, const std::set<Realisation> & startOutp
};
res.merge(computeClosure<Realisation>(startOutputs, getDeps));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
nlohmann::json Realisation::toJSON() const {
+4 -2
View File
@@ -68,8 +68,10 @@ struct Realisation {
bool checkSignature(const PublicKeys & publicKeys, const std::string & sig) const;
size_t checkSignatures(const PublicKeys & publicKeys) const;
static std::set<Realisation> closure(Store &, const std::set<Realisation> &);
static void closure(Store &, const std::set<Realisation> &, std::set<Realisation> & res);
static kj::Promise<Result<std::set<Realisation>>>
closure(Store &, const std::set<Realisation> &);
static kj::Promise<Result<void>>
closure(Store &, const std::set<Realisation> &, std::set<Realisation> & res);
bool isCompatibleWith(const Realisation & other) const;
+2 -1
View File
@@ -1194,7 +1194,8 @@ try {
try {
// Copy the realisation closure
processGraph<Realisation>(
"copyPaths pool", Realisation::closure(srcStore, toplevelRealisations),
"copyPaths pool",
TRY_AWAIT(Realisation::closure(srcStore, toplevelRealisations)),
[&](const Realisation & current) -> std::set<Realisation> {
std::set<Realisation> children;
for (const auto & [drvOutput, _] : current.dependentRealisations) {