libstore: asyncify Store::querySubstitutablePaths

the LocalStore implementation calls `getDefaultSubstituters`, which
calls `openStore`, which calls `Store::init`, which does network io
in binary caches, which will eventually be properly asyncified curl

Change-Id: If6a7a0294e2c4ba8e35722583be6ccde21ed6585
This commit is contained in:
eldritch horrors
2025-02-08 12:45:15 +00:00
parent 6e12f8922c
commit c2f71d5b30
7 changed files with 20 additions and 13 deletions
+2 -2
View File
@@ -231,7 +231,7 @@ static bool isPrebuilt(EvalState & state, DrvInfo & elem)
{
auto path = elem.queryOutPath(state);
if (state.ctx.store->isValidPath(path)) return true;
return state.ctx.store->querySubstitutablePaths({path}).count(path);
return state.aio.blockOn(state.ctx.store->querySubstitutablePaths({path})).count(path);
}
@@ -1103,7 +1103,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
i.setFailed();
}
validPaths = store.queryValidPaths(paths);
substitutablePaths = store.querySubstitutablePaths(paths);
substitutablePaths = globals.aio.blockOn(store.querySubstitutablePaths(paths));
}
+1 -1
View File
@@ -300,7 +300,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
case WorkerProto::Op::QuerySubstitutablePaths: {
auto paths = WorkerProto::Serialise<StorePathSet>::read(*store, rconn);
logger->startWork();
auto res = store->querySubstitutablePaths(paths);
auto res = aio.blockOn(store->querySubstitutablePaths(paths));
logger->stopWork();
to << WorkerProto::write(*store, wconn, res);
break;
+6 -4
View File
@@ -1062,9 +1062,9 @@ std::optional<StorePath> LocalStore::queryPathFromHashPart(const std::string & h
}
StorePathSet LocalStore::querySubstitutablePaths(const StorePathSet & paths)
{
if (!settings.useSubstitutes) return StorePathSet();
kj::Promise<Result<StorePathSet>> LocalStore::querySubstitutablePaths(const StorePathSet & paths)
try {
if (!settings.useSubstitutes) co_return StorePathSet();
StorePathSet remaining;
for (auto & i : paths)
@@ -1089,7 +1089,9 @@ StorePathSet LocalStore::querySubstitutablePaths(const StorePathSet & paths)
std::swap(remaining, remaining2);
}
return res;
co_return res;
} catch (...) {
co_return result::current_exception();
}
+1 -1
View File
@@ -199,7 +199,7 @@ public:
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;
kj::Promise<Result<StorePathSet>> querySubstitutablePaths(const StorePathSet & paths) override;
bool pathInfoIsUntrusted(const ValidPathInfo &) override;
bool realisationIsUntrusted(const Realisation & ) override;
+5 -3
View File
@@ -227,13 +227,15 @@ StorePathSet RemoteStore::queryAllValidPaths()
}
StorePathSet RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
{
kj::Promise<Result<StorePathSet>> RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
try {
auto conn(getConnection());
conn->to << WorkerProto::Op::QuerySubstitutablePaths;
conn->to << WorkerProto::write(*this, *conn, paths);
conn.processStderr();
return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
return {WorkerProto::Serialise<StorePathSet>::read(*this, *conn)};
} catch (...) {
return {result::current_exception()};
}
+1 -1
View File
@@ -66,7 +66,7 @@ public:
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path, Store * evalStore = nullptr) override;
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;
kj::Promise<Result<StorePathSet>> querySubstitutablePaths(const StorePathSet & paths) override;
void querySubstitutablePathInfos(const StorePathCAMap & paths,
SubstitutablePathInfos & infos) override;
+4 -1
View File
@@ -477,7 +477,10 @@ public:
/**
* Query which of the given paths have substitutes.
*/
virtual StorePathSet querySubstitutablePaths(const StorePathSet & paths) { return {}; };
virtual kj::Promise<Result<StorePathSet>> querySubstitutablePaths(const StorePathSet & paths)
{
return {StorePathSet{}};
}
/**
* Query substitute info (i.e. references, derivers and download