summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcore/src/tests/proton/index/indexcollection_test.cpp14
-rw-r--r--searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/index/indexmanager.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.h19
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp14
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h26
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h6
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp12
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h4
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.cpp2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.h6
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp33
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h17
18 files changed, 93 insertions, 80 deletions
diff --git a/searchcore/src/tests/proton/index/indexcollection_test.cpp b/searchcore/src/tests/proton/index/indexcollection_test.cpp
index 07fbacde49a..70141f057bf 100644
--- a/searchcore/src/tests/proton/index/indexcollection_test.cpp
+++ b/searchcore/src/tests/proton/index/indexcollection_test.cpp
@@ -25,7 +25,7 @@ public:
MockIndexSearchable()
: _field_length_info()
{}
- MockIndexSearchable(const FieldLengthInfo& field_length_info)
+ explicit MockIndexSearchable(const FieldLengthInfo& field_length_info)
: _field_length_info(field_length_info)
{}
FieldLengthInfo get_field_length_info(const vespalib::string& field_name) const override {
@@ -79,17 +79,17 @@ public:
return std::make_unique<WarmupIndexCollection>(WarmupConfig(1s, false), prev, next, *_warmup, _executor, *this);
}
- virtual void warmupDone(ISearchableIndexCollection::SP current) override {
+ void warmupDone(std::shared_ptr<WarmupIndexCollection> current) override {
(void) current;
}
IndexCollectionTest()
- : _selector(new FixedSourceSelector(0, "fs1")),
- _source1(new MockIndexSearchable({3, 5})),
- _source2(new MockIndexSearchable({7, 11})),
- _fusion_source(new FakeIndexSearchable),
+ : _selector(std::make_shared<FixedSourceSelector>(0, "fs1")),
+ _source1(std::make_shared<MockIndexSearchable>(FieldLengthInfo(3, 5))),
+ _source2(std::make_shared<MockIndexSearchable>(FieldLengthInfo(7, 11))),
+ _fusion_source(std::make_shared<FakeIndexSearchable>()),
_executor(1, 128_Ki),
- _warmup(new FakeIndexSearchable)
+ _warmup(std::make_shared<FakeIndexSearchable>())
{}
~IndexCollectionTest() = default;
};
diff --git a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp
index 9e915779d92..630c536a1ca 100644
--- a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp
@@ -15,7 +15,7 @@ IndexManagerInitializer(const vespalib::string &baseDir,
search::SerialNum serialNum,
searchcorespi::IIndexManager::Reconfigurer & reconfigurer,
searchcorespi::index::IThreadingService & threadingService,
- vespalib::SyncableThreadExecutor & warmupExecutor,
+ vespalib::Executor & warmupExecutor,
const search::TuneFileIndexManager & tuneFileIndexManager,
const search::TuneFileAttributes &tuneFileAttributes,
const search::common::FileHeaderContext & fileHeaderContext,
diff --git a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h
index a7acfb61d54..3cf1daf631e 100644
--- a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h
+++ b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h
@@ -20,7 +20,7 @@ class IndexManagerInitializer : public initializer::InitializerTask
search::SerialNum _serialNum;
searchcorespi::IIndexManager::Reconfigurer &_reconfigurer;
searchcorespi::index::IThreadingService &_threadingService;
- vespalib::SyncableThreadExecutor &_warmupExecutor;
+ vespalib::Executor &_warmupExecutor;
const search::TuneFileIndexManager _tuneFileIndexManager;
const search::TuneFileAttributes _tuneFileAttributes;
const search::common::FileHeaderContext &_fileHeaderContext;
@@ -33,7 +33,7 @@ public:
search::SerialNum serialNum,
searchcorespi::IIndexManager::Reconfigurer & reconfigurer,
searchcorespi::index::IThreadingService & threadingService,
- vespalib::SyncableThreadExecutor & warmupExecutor,
+ vespalib::Executor & warmupExecutor,
const search::TuneFileIndexManager & tuneFileIndexManager,
const search::TuneFileAttributes & tuneFileAttributes,
const search::common::FileHeaderContext & fileHeaderContext,
diff --git a/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp b/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp
index 169ba149297..de397e81d76 100644
--- a/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp
@@ -80,7 +80,7 @@ IndexManager::IndexManager(const vespalib::string &baseDir,
SerialNum serialNum,
Reconfigurer &reconfigurer,
IThreadingService &threadingService,
- vespalib::SyncableThreadExecutor & warmupExecutor,
+ vespalib::Executor & warmupExecutor,
const search::TuneFileIndexManager &tuneFileIndexManager,
const search::TuneFileAttributes &tuneFileAttributes,
const FileHeaderContext &fileHeaderContext) :
diff --git a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h
index 4113af30b0d..436b4127804 100644
--- a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h
+++ b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h
@@ -73,7 +73,7 @@ public:
SerialNum serialNum,
Reconfigurer &reconfigurer,
searchcorespi::index::IThreadingService &threadingService,
- vespalib::SyncableThreadExecutor & warmupExecutor,
+ vespalib::Executor & warmupExecutor,
const search::TuneFileIndexManager &tuneFileIndexManager,
const search::TuneFileAttributes &tuneFileAttributes,
const search::common::FileHeaderContext &fileHeaderContext);
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index 0d45a287fdc..e5bf5013528 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -131,7 +131,7 @@ DocumentDB::create(const vespalib::string &baseDir,
document::BucketSpace bucketSpace,
const ProtonConfig &protonCfg,
IDocumentDBOwner &owner,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::ThreadExecutor &warmupExecutor,
vespalib::ThreadExecutor &sharedExecutor,
storage::spi::BucketExecutor &bucketExecutor,
const search::transactionlog::WriterFactory &tlsWriterFactory,
@@ -155,7 +155,7 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir,
document::BucketSpace bucketSpace,
const ProtonConfig &protonCfg,
IDocumentDBOwner &owner,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::Executor &warmupExecutor,
vespalib::ThreadExecutor &sharedExecutor,
storage::spi::BucketExecutor & bucketExecutor,
const search::transactionlog::WriterFactory &tlsWriterFactory,
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
index 391c11df276..ee414db28bf 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
@@ -71,10 +71,15 @@ class DocumentDB : public DocumentDBConfigOwner,
public std::enable_shared_from_this<DocumentDB>
{
private:
- using InitializeThreads = std::shared_ptr<vespalib::SyncableThreadExecutor>;
+ using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>;
using IFlushTargetList = std::vector<std::shared_ptr<searchcorespi::IFlushTarget>>;
using StatusReportUP = std::unique_ptr<StatusReport>;
using ProtonConfig = const vespa::config::search::core::internal::InternalProtonType;
+ using ConfigComparisonResult = DocumentDBConfig::ComparisonResult;
+ using lock_guard = std::lock_guard<std::mutex>;
+ using SerialNum = search::SerialNum;
+ using Schema = search::index::Schema;
+
DocTypeName _docTypeName;
document::BucketSpace _bucketSpace;
@@ -85,9 +90,6 @@ private:
// threads for initializer tasks during proton startup
InitializeThreads _initializeThreads;
- typedef search::SerialNum SerialNum;
- typedef search::index::Schema Schema;
- using lock_guard = std::lock_guard<std::mutex>;
// variables related to reconfig
DocumentDBConfig::SP _initConfigSnapshot;
SerialNum _initConfigSerialNum;
@@ -97,10 +99,7 @@ private:
DocumentDBConfig::SP _activeConfigSnapshot;
int64_t _activeConfigSnapshotGeneration;
const bool _validateAndSanitizeDocStore;
-
- vespalib::Gate _initGate;
-
- typedef DocumentDBConfig::ComparisonResult ConfigComparisonResult;
+ vespalib::Gate _initGate;
ClusterStateHandler _clusterStateHandler;
BucketHandler _bucketHandler;
@@ -201,7 +200,7 @@ private:
document::BucketSpace bucketSpace,
const ProtonConfig &protonCfg,
IDocumentDBOwner &owner,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::Executor &warmupExecutor,
vespalib::ThreadExecutor &sharedExecutor,
storage::spi::BucketExecutor &bucketExecutor,
const search::transactionlog::WriterFactory &tlsWriterFactory,
@@ -233,7 +232,7 @@ public:
document::BucketSpace bucketSpace,
const ProtonConfig &protonCfg,
IDocumentDBOwner &owner,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::ThreadExecutor &warmupExecutor,
vespalib::ThreadExecutor &sharedExecutor,
storage::spi::BucketExecutor & bucketExecutor,
const search::transactionlog::WriterFactory &tlsWriterFactory,
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
index 6576e4ead97..3c9bdb2ec5f 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp
@@ -26,7 +26,7 @@ DocumentSubDBCollection::DocumentSubDBCollection(
const IGetSerialNum &getSerialNum,
const DocTypeName &docTypeName,
searchcorespi::index::IThreadingService &writeService,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::Executor &warmupExecutor,
const search::common::FileHeaderContext &fileHeaderContext,
MetricsWireService &metricsWireService,
DocumentDBTaggedMetrics &metrics,
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h
index 515a886969c..ca092bb0957 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h
@@ -12,7 +12,7 @@
namespace vespalib {
class Clock;
- class SyncableThreadExecutor;
+ class Executor;
class ThreadStackExecutorBase;
}
@@ -86,7 +86,7 @@ public:
const IGetSerialNum &getSerialNum,
const DocTypeName &docTypeName,
searchcorespi::index::IThreadingService &writeService,
- vespalib::SyncableThreadExecutor &warmupExecutor,
+ vespalib::Executor &warmupExecutor,
const search::common::FileHeaderContext &fileHeaderContext,
MetricsWireService &metricsWireService,
DocumentDBTaggedMetrics &metrics,
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp
index 73c63da622d..70195980376 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.cpp
@@ -5,18 +5,18 @@
#include <vespa/vespalib/data/slime/cursor.h>
#include <vespa/vespalib/util/threadexecutor.h>
-using vespalib::SyncableThreadExecutor;
+using vespalib::ThreadExecutor;
namespace proton {
using explorer::convert_executor_to_slime;
-ProtonThreadPoolsExplorer::ProtonThreadPoolsExplorer(const SyncableThreadExecutor* shared,
- const SyncableThreadExecutor* match,
- const SyncableThreadExecutor* docsum,
- const SyncableThreadExecutor* flush,
- const SyncableThreadExecutor* proton,
- const SyncableThreadExecutor* warmup)
+ProtonThreadPoolsExplorer::ProtonThreadPoolsExplorer(const ThreadExecutor* shared,
+ const ThreadExecutor* match,
+ const ThreadExecutor* docsum,
+ const ThreadExecutor* flush,
+ const ThreadExecutor* proton,
+ const ThreadExecutor* warmup)
: _shared(shared),
_match(match),
_docsum(docsum),
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h
index 7f0873a750d..76c5fa8cfb0 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton_thread_pools_explorer.h
@@ -4,7 +4,7 @@
#include <vespa/vespalib/net/state_explorer.h>
-namespace vespalib { class SyncableThreadExecutor; }
+namespace vespalib { class ThreadExecutor; }
namespace proton {
@@ -13,20 +13,20 @@ namespace proton {
*/
class ProtonThreadPoolsExplorer : public vespalib::StateExplorer {
private:
- const vespalib::SyncableThreadExecutor* _shared;
- const vespalib::SyncableThreadExecutor* _match;
- const vespalib::SyncableThreadExecutor* _docsum;
- const vespalib::SyncableThreadExecutor* _flush;
- const vespalib::SyncableThreadExecutor* _proton;
- const vespalib::SyncableThreadExecutor* _warmup;
+ const vespalib::ThreadExecutor* _shared;
+ const vespalib::ThreadExecutor* _match;
+ const vespalib::ThreadExecutor* _docsum;
+ const vespalib::ThreadExecutor* _flush;
+ const vespalib::ThreadExecutor* _proton;
+ const vespalib::ThreadExecutor* _warmup;
public:
- ProtonThreadPoolsExplorer(const vespalib::SyncableThreadExecutor* shared,
- const vespalib::SyncableThreadExecutor* match,
- const vespalib::SyncableThreadExecutor* docsum,
- const vespalib::SyncableThreadExecutor* flush,
- const vespalib::SyncableThreadExecutor* proton,
- const vespalib::SyncableThreadExecutor* warmup);
+ ProtonThreadPoolsExplorer(const vespalib::ThreadExecutor* shared,
+ const vespalib::ThreadExecutor* match,
+ const vespalib::ThreadExecutor* docsum,
+ const vespalib::ThreadExecutor* flush,
+ const vespalib::ThreadExecutor* proton,
+ const vespalib::ThreadExecutor* warmup);
void get_state(const vespalib::slime::Inserter& inserter, bool full) const override;
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
index ea758443cd4..e6da0e958e8 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
@@ -45,12 +45,12 @@ public:
const FastAccessDocSubDB::Context _fastUpdCtx;
matching::QueryLimiter &_queryLimiter;
const vespalib::Clock &_clock;
- vespalib::SyncableThreadExecutor &_warmupExecutor;
+ vespalib::Executor &_warmupExecutor;
Context(const FastAccessDocSubDB::Context &fastUpdCtx,
matching::QueryLimiter &queryLimiter,
const vespalib::Clock &clock,
- vespalib::SyncableThreadExecutor &warmupExecutor)
+ vespalib:: Executor &warmupExecutor)
: _fastUpdCtx(fastUpdCtx),
_queryLimiter(queryLimiter),
_clock(clock),
@@ -70,7 +70,7 @@ private:
vespalib::eval::ConstantValueCache _constantValueCache;
matching::ConstantValueRepo _constantValueRepo;
SearchableDocSubDBConfigurer _configurer;
- vespalib::SyncableThreadExecutor &_warmupExecutor;
+ vespalib::Executor &_warmupExecutor;
std::shared_ptr<GidToLidChangeHandler> _realGidToLidChangeHandler;
DocumentDBFlushConfig _flushConfig;
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 19469d59d1b..a2bd19c3d29 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -328,10 +328,8 @@ IndexMaintainer::flushMemoryIndex(IMemoryIndex &memoryIndex,
updateDiskIndexSchema(flushDir, *prunedSchema, noSerialNumHigh);
}
IndexWriteUtilities::writeSourceSelector(saveInfo, indexId, getAttrTune(),
- _ctx.getFileHeaderContext(),
- serialNum);
- IndexWriteUtilities::writeSerialNum(serialNum, flushDir,
- _ctx.getFileHeaderContext());
+ _ctx.getFileHeaderContext(), serialNum);
+ IndexWriteUtilities::writeSerialNum(serialNum, flushDir, _ctx.getFileHeaderContext());
return loadDiskIndex(flushDir);
}
@@ -696,7 +694,7 @@ IndexMaintainer::doneFusion(FusionArgs *args, IDiskIndex::SP *new_index)
}
bool
-IndexMaintainer::makeSureAllRemainingWarmupIsDone(ISearchableIndexCollection::SP keepAlive)
+IndexMaintainer::makeSureAllRemainingWarmupIsDone(std::shared_ptr<WarmupIndexCollection> keepAlive)
{
// called by warmupDone via reconfigurer, warmupDone() doesn't wait for us
assert(_ctx.getThreadingService().master().isCurrentThread());
@@ -713,13 +711,13 @@ IndexMaintainer::makeSureAllRemainingWarmupIsDone(ISearchableIndexCollection::SP
LOG(info, "New index warmed up and switched in : %s", warmIndex->toString().c_str());
}
LOG(info, "Sync warmupExecutor.");
- _ctx.getWarmupExecutor().sync();
+ keepAlive->drainPending();
LOG(info, "Now the keep alive of the warmupindexcollection should be gone.");
return true;
}
void
-IndexMaintainer::warmupDone(ISearchableIndexCollection::SP current)
+IndexMaintainer::warmupDone(std::shared_ptr<WarmupIndexCollection> current)
{
// Called by a search thread
LockGuard lock(_new_search_lock);
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
index 6e4eb32ee50..8213c02b90c 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
@@ -257,8 +257,8 @@ class IndexMaintainer : public IIndexManager,
* result.
*/
bool reconfigure(std::unique_ptr<Configure> configure);
- void warmupDone(ISearchableIndexCollection::SP current) override;
- bool makeSureAllRemainingWarmupIsDone(ISearchableIndexCollection::SP keepAlive);
+ void warmupDone(std::shared_ptr<WarmupIndexCollection> current) override;
+ bool makeSureAllRemainingWarmupIsDone(std::shared_ptr<WarmupIndexCollection> keepAlive);
void commit_and_wait();
void commit(vespalib::Gate& gate);
void pruneRemovedFields(const Schema &schema, SerialNum serialNum);
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.cpp
index 522789e7fe8..efd7827fc3d 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.cpp
@@ -11,7 +11,7 @@ namespace searchcorespi::index {
IndexMaintainerContext::IndexMaintainerContext(IThreadingService &threadingService,
IIndexManager::Reconfigurer &reconfigurer,
const FileHeaderContext &fileHeaderContext,
- vespalib::SyncableThreadExecutor & warmupExecutor)
+ vespalib::Executor & warmupExecutor)
: _threadingService(threadingService),
_reconfigurer(reconfigurer),
_fileHeaderContext(fileHeaderContext),
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.h
index c90659c55bf..2c7aa4af48e 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainercontext.h
@@ -17,13 +17,13 @@ private:
IThreadingService &_threadingService;
IIndexManager::Reconfigurer &_reconfigurer;
const search::common::FileHeaderContext &_fileHeaderContext;
- vespalib::SyncableThreadExecutor & _warmupExecutor;
+ vespalib::Executor & _warmupExecutor;
public:
IndexMaintainerContext(IThreadingService &threadingService,
IIndexManager::Reconfigurer &reconfigurer,
const search::common::FileHeaderContext &fileHeaderContext,
- vespalib::SyncableThreadExecutor & warmupExecutor);
+ vespalib::Executor & warmupExecutor);
/**
* Returns the treading service that encapsulates the thread model used for writing.
@@ -49,7 +49,7 @@ public:
/**
* @return The executor that should be used for warmup.
*/
- vespalib::SyncableThreadExecutor & getWarmupExecutor() const { return _warmupExecutor; }
+ vespalib::Executor & getWarmupExecutor() const { return _warmupExecutor; }
};
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
index d6aba7c6ff1..0a24efd0e66 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
@@ -5,6 +5,7 @@
#include <vespa/searchlib/query/tree/termnodes.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/stllike/hash_set.h>
+#include <thread>
#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.warmupindexcollection");
@@ -29,7 +30,7 @@ WarmupIndexCollection::WarmupIndexCollection(const WarmupConfig & warmupConfig,
ISearchableIndexCollection::SP prev,
ISearchableIndexCollection::SP next,
IndexSearchable & warmup,
- vespalib::SyncableThreadExecutor & executor,
+ vespalib::Executor & executor,
IWarmupDone & warmupDone) :
_warmupConfig(warmupConfig),
_prev(std::move(prev)),
@@ -38,7 +39,8 @@ WarmupIndexCollection::WarmupIndexCollection(const WarmupConfig & warmupConfig,
_executor(executor),
_warmupDone(warmupDone),
_warmupEndTime(vespalib::steady_clock::now() + warmupConfig.getDuration()),
- _handledTerms(std::make_unique<FieldTermMap>())
+ _handledTerms(std::make_unique<FieldTermMap>()),
+ _pendingTasks(0)
{
if (_next->valid()) {
setCurrentIndex(_next->getCurrentIndex());
@@ -79,7 +81,7 @@ WarmupIndexCollection::~WarmupIndexCollection()
if (_warmupEndTime != vespalib::steady_time()) {
LOG(info, "Warmup aborted due to new state change or application shutdown");
}
- _executor.sync();
+ assert(_pendingTasks == 0);
}
const ISourceSelector &
@@ -164,7 +166,7 @@ WarmupIndexCollection::createBlueprint(const IRequestContext & requestContext,
needWarmUp = needWarmUp || ! handledBefore(fs.getFieldId(), term);
}
if (needWarmUp) {
- auto task = std::make_unique<WarmupTask>(mdl.createMatchData(), *this);
+ auto task = std::make_unique<WarmupTask>(mdl.createMatchData(), shared_from_this());
task->createBlueprint(fsl, term);
fireWarmup(std::move(task));
}
@@ -216,25 +218,36 @@ WarmupIndexCollection::getSearchableSP(uint32_t i) const
return _next->getSearchableSP(i);
}
-WarmupIndexCollection::WarmupTask::WarmupTask(std::unique_ptr<MatchData> md, WarmupIndexCollection & warmup)
- : _warmup(warmup),
+void
+WarmupIndexCollection::drainPending() {
+ while (_pendingTasks > 0) {
+ std::this_thread::sleep_for(1ms);
+ }
+}
+
+WarmupIndexCollection::WarmupTask::WarmupTask(std::unique_ptr<MatchData> md, std::shared_ptr<WarmupIndexCollection> warmup)
+ : _warmup(std::move(warmup)),
_matchData(std::move(md)),
_bluePrint(),
_requestContext()
-{ }
+{
+ _warmup->_pendingTasks++;
+}
-WarmupIndexCollection::WarmupTask::~WarmupTask() = default;
+WarmupIndexCollection::WarmupTask::~WarmupTask() {
+ _warmup->_pendingTasks--;
+}
void
WarmupIndexCollection::WarmupTask::run()
{
- if (_warmup._warmupEndTime != vespalib::steady_time()) {
+ if (_warmup->_warmupEndTime != vespalib::steady_time()) {
LOG(debug, "Warming up %s", _bluePrint->asString().c_str());
_bluePrint->fetchPostings(search::queryeval::ExecuteInfo::TRUE);
SearchIterator::UP it(_bluePrint->createSearch(*_matchData, true));
it->initFullRange();
for (uint32_t docId = it->seekFirst(1); !it->isAtEnd(); docId = it->seekNext(docId+1)) {
- if (_warmup.doUnpack()) {
+ if (_warmup->doUnpack()) {
it->unpack(docId);
}
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
index d18e43b56a7..5292fb36298 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h
@@ -10,11 +10,12 @@
namespace searchcorespi {
class FieldTermMap;
+class WarmupIndexCollection;
class IWarmupDone {
public:
virtual ~IWarmupDone() { }
- virtual void warmupDone(ISearchableIndexCollection::SP current) = 0;
+ virtual void warmupDone(std::shared_ptr<WarmupIndexCollection> current) = 0;
};
/**
* Index collection that holds a reference to the active one and a new one that
@@ -30,7 +31,7 @@ public:
ISearchableIndexCollection::SP prev,
ISearchableIndexCollection::SP next,
IndexSearchable & warmup,
- vespalib::SyncableThreadExecutor & executor,
+ vespalib::Executor & executor,
IWarmupDone & warmupDone);
~WarmupIndexCollection() override;
// Implements IIndexCollection
@@ -64,25 +65,26 @@ public:
const ISearchableIndexCollection::SP & getNextIndexCollection() const { return _next; }
vespalib::string toString() const override;
bool doUnpack() const { return _warmupConfig.getUnpack(); }
+ void drainPending();
private:
typedef search::fef::MatchData MatchData;
typedef search::queryeval::FakeRequestContext FakeRequestContext;
typedef vespalib::Executor::Task Task;
class WarmupTask : public Task {
public:
- WarmupTask(std::unique_ptr<MatchData> md, WarmupIndexCollection & warmup);
+ WarmupTask(std::unique_ptr<MatchData> md, std::shared_ptr<WarmupIndexCollection> warmup);
~WarmupTask() override;
WarmupTask &createBlueprint(const FieldSpec &field, const Node &term) {
- _bluePrint = _warmup.createBlueprint(_requestContext, field, term);
+ _bluePrint = _warmup->createBlueprint(_requestContext, field, term);
return *this;
}
WarmupTask &createBlueprint(const FieldSpecList &fields, const Node &term) {
- _bluePrint = _warmup.createBlueprint(_requestContext, fields, term);
+ _bluePrint = _warmup->createBlueprint(_requestContext, fields, term);
return *this;
}
private:
void run() override;
- WarmupIndexCollection & _warmup;
+ std::shared_ptr<WarmupIndexCollection> _warmup;
std::unique_ptr<MatchData> _matchData;
Blueprint::UP _bluePrint;
FakeRequestContext _requestContext;
@@ -95,11 +97,12 @@ private:
ISearchableIndexCollection::SP _prev;
ISearchableIndexCollection::SP _next;
IndexSearchable & _warmup;
- vespalib::SyncableThreadExecutor & _executor;
+ vespalib::Executor & _executor;
IWarmupDone & _warmupDone;
vespalib::steady_time _warmupEndTime;
std::mutex _lock;
std::unique_ptr<FieldTermMap> _handledTerms;
+ std::atomic<uint64_t> _pendingTasks;
};
} // namespace searchcorespi