From 9f01a3f0a87679ac3ba2c71ab6d31478bcbef481 Mon Sep 17 00:00:00 2001 From: AmineChikhaoui Date: Wed, 25 Oct 2017 16:13:49 +0100 Subject: [PATCH 1/2] attempt to fix #1630: make the queries of store paths run in parallel using a thread pool --- src/libstore/store-api.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index c57e42fec..82e0bda54 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -389,8 +389,9 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti Sync state_(State{paths.size(), PathSet()}); std::condition_variable wakeup; + ThreadPool pool; - for (auto & path : paths) + auto doQuery = [&](const Path & path ) { queryPathInfo(path, [path, &state_, &wakeup](ref info) { auto state(state_.lock()); @@ -411,6 +412,12 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti if (!--state->left) wakeup.notify_one(); }); + }; + + for (auto & path : paths) + pool.enqueue(std::bind(doQuery, path)); + + pool.process(); while (true) { auto state(state_.lock()); From 0f9a7225ab47fe313db41f4019177be8fb84a1dd Mon Sep 17 00:00:00 2001 From: AmineChikhaoui Date: Wed, 25 Oct 2017 16:51:45 +0100 Subject: [PATCH 2/2] respect SIGINT in nix copy during the paths queries #1629 --- src/libstore/store-api.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 82e0bda54..3631e1b30 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -392,6 +392,7 @@ PathSet Store::queryValidPaths(const PathSet & paths, SubstituteFlag maybeSubsti ThreadPool pool; auto doQuery = [&](const Path & path ) { + checkInterrupt(); queryPathInfo(path, [path, &state_, &wakeup](ref info) { auto state(state_.lock());