diff --git a/doc/manual/rl-next/parallelise-signs.md b/doc/manual/rl-next/parallelise-signs.md new file mode 100644 index 000000000..6be48b7d5 --- /dev/null +++ b/doc/manual/rl-next/parallelise-signs.md @@ -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`. diff --git a/lix/nix/sigs.cc b/lix/nix/sigs.cc index 9146d1c69..1a7740c0a 100644 --- a/lix/nix/sigs.cc +++ b/lix/nix/sigs.cc @@ -115,9 +115,16 @@ struct CmdSign : StorePathsCommand SecretKey secretKey(readFile(secretKeyFile)); - size_t added{0}; + ThreadPool pool{"Sign pool"}; + + std::atomic 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); }