libstore: asyncify staticOutputHashes

Change-Id: Idb0daa96021656258c8018bb47cdf3c77871be0d
This commit is contained in:
eldritch horrors
2025-03-05 18:49:45 +01:00
parent 03ab0fcb53
commit fc0bea42c2
8 changed files with 18 additions and 12 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ connected:
}
auto outputHashes = staticOutputHashes(*store, drv);
auto outputHashes = aio.blockOn(staticOutputHashes(*store, drv));
std::set<Realisation> missingRealisations;
StorePathSet missingPaths;
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations) && !drv.type().hasKnownOutputPaths()) {
+2 -1
View File
@@ -4,6 +4,7 @@
#include "lix/libutil/async.hh"
#include "lix/libutil/result.hh"
#include <kj/async.h>
#include <nlohmann/json.hpp>
#include <optional>
@@ -142,7 +143,7 @@ try {
[&](const BuiltPath::Built & p) -> kj::Promise<Result<void>> {
try {
auto drvHashes =
staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
TRY_AWAIT(staticOutputHashes(store, store.readDerivation(p.drvPath->outPath())));
for (auto& [outputName, outputPath] : p.outputs) {
if (experimentalFeatureSettings.isEnabled(
Xp::CaDerivations)) {
+2 -2
View File
@@ -253,7 +253,7 @@ try {
if (i.second.second)
TRY_AWAIT(worker.store.addTempRoot(*i.second.second));
auto outputHashes = staticOutputHashes(worker.evalStore, *drv);
auto outputHashes = TRY_AWAIT(staticOutputHashes(worker.evalStore, *drv));
for (auto & [outputName, outputHash] : outputHashes)
initialOutputs.insert({
outputName,
@@ -1151,7 +1151,7 @@ try {
SingleDrvOutputs builtOutputs;
if (resolvedResult.success()) {
auto resolvedHashes = staticOutputHashes(worker.store, resolvedDrv);
auto resolvedHashes = TRY_AWAIT(staticOutputHashes(worker.store, resolvedDrv));
StorePathSet outputPaths;
+6 -3
View File
@@ -892,9 +892,12 @@ DrvHash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOut
}
std::map<std::string, Hash> staticOutputHashes(Store & store, const Derivation & drv)
{
return hashDerivationModulo(store, drv, true).hashes;
kj::Promise<Result<std::map<std::string, Hash>>>
staticOutputHashes(Store & store, const Derivation & drv)
try {
co_return hashDerivationModulo(store, drv, true).hashes;
} catch (...) {
co_return result::current_exception();
}
+2 -1
View File
@@ -483,7 +483,8 @@ DrvHash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOut
*
* \todo What is the Hash in this map?
*/
std::map<std::string, Hash> staticOutputHashes(Store & store, const Derivation & drv);
kj::Promise<Result<std::map<std::string, Hash>>>
staticOutputHashes(Store & store, const Derivation & drv);
/**
* Memoisation of hashDerivationModulo().
+2 -2
View File
@@ -267,7 +267,7 @@ struct QueryMissingContext
// If there are unknown output paths, attempt to find if the
// paths are known to substituters through a realisation.
auto outputHashes = staticOutputHashes(store, *drv);
auto outputHashes = aio.blockOn(staticOutputHashes(store, *drv));
knownOutputPaths = true;
for (auto [outputName, hash] : outputHashes) {
@@ -425,7 +425,7 @@ try {
try {
if (!inputNode.value.empty()) {
auto outputHashes =
staticOutputHashes(evalStore, evalStore.readDerivation(inputDrv));
TRY_AWAIT(staticOutputHashes(evalStore, evalStore.readDerivation(inputDrv)));
for (const auto & outputName : inputNode.value) {
auto outputHash = get(outputHashes, outputName);
if (!outputHash)
+2 -1
View File
@@ -758,7 +758,8 @@ try {
OutputPathMap outputs;
auto drvPath = TRY_AWAIT(resolveDerivedPath(*evalStore, *bfd.drvPath));
auto drv = evalStore->readDerivation(drvPath);
const auto outputHashes = staticOutputHashes(*evalStore, drv); // FIXME: expensive
const auto outputHashes =
TRY_AWAIT(staticOutputHashes(*evalStore, drv)); // FIXME: expensive
auto built = TRY_AWAIT(resolveDerivedPath(*this, bfd, &*evalStore));
for (auto & [output, outputPath] : built) {
auto outputHash = get(outputHashes, output);
+1 -1
View File
@@ -530,7 +530,7 @@ try {
co_return outputs;
auto drv = evalStore.readInvalidDerivation(path);
auto drvHashes = staticOutputHashes(*this, drv);
auto drvHashes = TRY_AWAIT(staticOutputHashes(*this, drv));
for (auto & [outputName, hash] : drvHashes) {
auto realisation = TRY_AWAIT(queryRealisation(DrvOutput{hash, outputName}));
if (realisation) {