diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-24 18:58:42 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-24 18:58:42 +0000 |
commit | f4185f045d8929916d2ce023d395ce1ff58826c4 (patch) | |
tree | b6df78e7fd676f68e8e7e5a4371faeed8240534c /searchcore | |
parent | 25f41d6c5fd105b47d9f0d0c1642f25fd9ac8795 (diff) |
Use multiple threads during shutdown of documentdbs to speed up restart.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 22b50a65a41..cfd0ecc53d9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -8,12 +8,14 @@ #include "maintenancecontroller.h" #include "searchabledocsubdb.h" #include <vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h> +#include <vespa/vespalib/util/lambdatask.h> using proton::matching::SessionManager; using search::GrowStrategy; using search::SerialNum; using search::index::Schema; using searchcorespi::IFlushTarget; +using vespalib::makeLambdaTask; namespace proton { @@ -109,10 +111,26 @@ DocumentSubDBCollection::DocumentSubDBCollection( DocumentSubDBCollection::~DocumentSubDBCollection() { - for (auto subDb : _subDBs) { - delete subDb; + size_t numCores = std::max(1u, std::thread::hardware_concurrency()); + vespalib::ThreadStackExecutor closePool(std::min(_subDBs.size(), numCores), 0x20000); + while (!_subDBs.empty()) { + closePool.execute(makeLambdaTask([subDB=_subDBs.back()]() { delete subDB; })); + _subDBs.pop_back(); } + closePool.sync(); + _bucketDB.reset(); + + RetrieversSP retrievers = _retrievers.get(); + _retrievers.clear(); + if (retrievers) { + while (!retrievers->empty()) { + auto retriever = std::move(retrievers->back()); + retrievers->pop_back(); + closePool.execute(makeLambdaTask([r = std::move(retriever)]() mutable { r.reset(); })); + } + } + closePool.sync(); } void |