From 3cecd2306b53be389f1583cce68e8f7038e241c8 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 19 Aug 2025 15:00:10 +0200 Subject: [PATCH] nix/sigs: remove sign pool signing is very cheap, it's only the store access that is expensive. http binary caches parallelize async accesses extremely well though. Change-Id: Ifdbf398bd328ba16ec4e8caba3f5f99a6cf3e046 --- lix/nix/sigs.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/lix/nix/sigs.cc b/lix/nix/sigs.cc index 5a3973a8e..cbe661e19 100644 --- a/lix/nix/sigs.cc +++ b/lix/nix/sigs.cc @@ -5,7 +5,6 @@ #include "lix/libutil/async-collect.hh" #include "lix/libutil/async.hh" #include "lix/libutil/result.hh" -#include "lix/libutil/thread-pool.hh" #include "lix/libutil/signals.hh" #include "sigs.hh" @@ -119,33 +118,30 @@ struct CmdSign : StorePathsCommand SecretKey secretKey(readFile(secretKeyFile)); - ThreadPool pool{"Sign pool"}; + size_t added = 0; - std::atomic added{0}; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) + auto doPath = [&](const StorePath & storePath) -> kj::Promise> { + try { + auto info = TRY_AWAIT(store->queryPathInfo(storePath)); - auto doPath = [&](AsyncIoRoot & aio, const Path & storePathS) { - auto storePath = store->parseStorePath(storePathS); + auto info2(*info); + info2.sigs.clear(); + info2.sign(*store, secretKey); + assert(!info2.sigs.empty()); - auto info = aio.blockOn(store->queryPathInfo(storePath)); + if (!info->sigs.count(*info2.sigs.begin())) { + TRY_AWAIT(store->addSignatures(storePath, info2.sigs)); + added++; + } - auto info2(*info); - info2.sigs.clear(); - info2.sign(*store, secretKey); - assert(!info2.sigs.empty()); - - if (!info->sigs.count(*info2.sigs.begin())) { - aio.blockOn(store->addSignatures(storePath, info2.sigs)); - added++; + co_return result::success(); + } catch (...) { + co_return result::current_exception(); } }; - for (auto & storePath : storePaths) { - pool.enqueueWithAio( - std::bind(doPath, std::placeholders::_1, store->printStorePath(storePath)) - ); - } - - pool.process(); + aio().blockOn(asyncSpread(storePaths, doPath)); printInfo("added %d signatures", added); }