make nix store sign use a thread pool like nix store copy-sigs does

Fixes #399.

Change-Id: I0571036362eaf52a2efad99ba07788d7e3fd7f35
This commit is contained in:
Lunaphied
2025-02-20 04:28:28 +00:00
parent df336747e6
commit e335a26d5c
2 changed files with 26 additions and 3 deletions
+11
View File
@@ -0,0 +1,11 @@
---
synopsis: "Paralellise `nix store sign` using a thread pool"
issues: [399]
cls: [2606]
category: Fixes
credits: [Lunaphied]
---
`nix store sign` with a large collection of provided paths (such as when using with `--all`) has historically
signed these paths serially. Taking extreme amounts of time when preforming operations such as fixing binary
caches. This has been changed. Now these signatures are performed using a thread pool like `nix store copy-sigs`.
+15 -3
View File
@@ -115,9 +115,16 @@ struct CmdSign : StorePathsCommand
SecretKey secretKey(readFile(secretKeyFile));
size_t added{0};
ThreadPool pool{"Sign pool"};
std::atomic<size_t> added{0};
auto doPath = [&](const Path & storePathS) {
checkInterrupt();
auto storePath = store->parseStorePath(storePathS);
for (auto & storePath : storePaths) {
auto info = store->queryPathInfo(storePath);
auto info2(*info);
@@ -129,7 +136,12 @@ struct CmdSign : StorePathsCommand
store->addSignatures(storePath, info2.sigs);
added++;
}
}
};
for (auto & storePath : storePaths)
pool.enqueue(std::bind(doPath, store->printStorePath(storePath)));
pool.process();
printInfo("added %d signatures", added);
}