summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-12 08:59:43 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-11-12 08:59:43 +0000
commitcaeec93d81f88de278a7b324a6e023ee4449ee7b (patch)
tree81ee966d4f084e96714ada419735571939aa0fc4 /searchcore
parentccf1fa3639fa60ab775fdd0630bde5183d234a45 (diff)
When node is retired we can relax compaction strategy as we have peaked
in memory usage and will go reduce from here.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp11
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp36
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h6
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h5
10 files changed, 72 insertions, 14 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
index 4b6e67212e1..b4fc20d0c44 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp
@@ -575,6 +575,7 @@ AttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor>
{
for (const auto &attr : _attributes) {
if (attr.second.isExtra()) {
+ // TODO Why skip extra ?
continue;
}
AttributeVector::SP attrsp = attr.second.getAttribute();
@@ -584,6 +585,16 @@ AttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor>
}
void
+AttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const
+{
+ for (const auto &attr : _attributes) {
+ AttributeVector::SP attrsp = attr.second.getAttribute();
+ _attributeFieldWriter.execute(_attributeFieldWriter.getExecutorIdFromName(attrsp->getNamePrefix()),
+ [attrsp, func]() { (*func)(*attrsp); });
+ }
+}
+
+void
AttributeManager::asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const {
auto itr = _attributes.find(name);
if (itr == _attributes.end() || itr->second.isExtra() || !func) {
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
index 64f0418c299..e2b9550435d 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h
@@ -178,6 +178,7 @@ public:
const std::vector<search::AttributeVector *> &getWritableAttributes() const override;
void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override;
+ void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const override;
void asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const override;
ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const override;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
index 07bc1c638b5..c7ab83ae590 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp
@@ -206,6 +206,22 @@ FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IConstAttributeFun
}
void
+FilterAttributeManager::asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const
+{
+ // Run by document db master thread
+ std::vector<AttributeGuard> completeList;
+ _mgr->getAttributeList(completeList);
+ vespalib::ISequencedTaskExecutor &attributeFieldWriter = getAttributeFieldWriter();
+ for (auto &guard : completeList) {
+ search::AttributeVector::SP attrsp = guard.getSP();
+ // Name must be extracted in document db master thread or attribute
+ // writer thread
+ attributeFieldWriter.execute(attributeFieldWriter.getExecutorIdFromName(attrsp->getNamePrefix()),
+ [attrsp, func]() { (*func)(*attrsp); });
+ }
+}
+
+void
FilterAttributeManager::asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const {
AttributeGuard::UP attr = _mgr->getAttribute(name);
if (!attr) { return; }
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
index 9d09aef8faf..1ae5f452218 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.h
@@ -52,6 +52,7 @@ public:
search::AttributeVector * getWritableAttribute(const vespalib::string &name) const override;
const std::vector<search::AttributeVector *> & getWritableAttributes() const override;
void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const override;
+ void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const override;
ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const override;
void setImportedAttributes(std::unique_ptr<ImportedAttributesRepo> attributes) override;
const ImportedAttributesRepo *getImportedAttributes() const override;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
index 65796fd4c74..d55cd45d014 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h
@@ -98,6 +98,7 @@ struct IAttributeManager : public search::IAttributeManager
virtual const std::vector<search::AttributeVector *> &getWritableAttributes() const = 0;
virtual void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor> func) const = 0;
+ virtual void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor> func) const = 0;
virtual ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &name) const = 0;
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
index 3322722a642..b512143c5fd 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
@@ -5,7 +5,6 @@
#include "document_subdb_initializer.h"
#include "reconfig_params.h"
#include "i_document_subdb_owner.h"
-#include "ibucketstatecalculator.h"
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/common/alloc_config.h>
#include <vespa/searchcore/proton/flushengine/threadedflushtarget.h>
@@ -43,8 +42,7 @@ SearchableDocSubDB::SearchableDocSubDB(const Config &cfg, const Context &ctx)
getSubDbName(), ctx._fastUpdCtx._storeOnlyCtx._owner.getDistributionKey()),
_warmupExecutor(ctx._warmupExecutor),
_realGidToLidChangeHandler(std::make_shared<GidToLidChangeHandler>()),
- _flushConfig(),
- _nodeRetired(false)
+ _flushConfig()
{
_gidToLidChangeHandler = _realGidToLidChangeHandler;
}
@@ -177,14 +175,14 @@ SearchableDocSubDB::applyFlushConfig(const DocumentDBFlushConfig &flushConfig)
void
SearchableDocSubDB::propagateFlushConfig()
{
- uint32_t maxFlushed = _nodeRetired ? _flushConfig.getMaxFlushedRetired() : _flushConfig.getMaxFlushed();
+ uint32_t maxFlushed = isNodeRetired() ? _flushConfig.getMaxFlushedRetired() : _flushConfig.getMaxFlushed();
_indexMgr->setMaxFlushed(maxFlushed);
}
void
SearchableDocSubDB::setBucketStateCalculator(const std::shared_ptr<IBucketStateCalculator> &calc)
{
- _nodeRetired = calc->nodeRetired();
+ FastAccessDocSubDB::setBucketStateCalculator(calc);
propagateFlushConfig();
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
index c310aeb2a2b..2e7aac0a8d3 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h
@@ -81,7 +81,6 @@ private:
vespalib::SyncableThreadExecutor &_warmupExecutor;
std::shared_ptr<GidToLidChangeHandler> _realGidToLidChangeHandler;
DocumentDBFlushConfig _flushConfig;
- bool _nodeRetired;
// Note: lifetime of indexManager must be handled by caller.
std::shared_ptr<initializer::InitializerTask>
diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
index 7ab60270411..1dbda17855b 100644
--- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "storeonlydocsubdb.h"
#include "docstorevalidator.h"
#include "document_subdb_initializer.h"
#include "document_subdb_initializer_result.h"
@@ -7,7 +8,7 @@
#include "i_document_subdb_owner.h"
#include "minimal_document_retriever.h"
#include "reconfig_params.h"
-#include "storeonlydocsubdb.h"
+#include "ibucketstatecalculator.h"
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/bucketdb/ibucketdbhandlerinitializer.h>
#include <vespa/searchcore/proton/common/alloc_config.h>
@@ -111,6 +112,7 @@ StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx)
_dmsFlushTarget(),
_dmsShrinkTarget(),
_pendingLidsForCommit(std::make_shared<PendingLidTracker>()),
+ _nodeRetired(false),
_subDbId(cfg._subDbId),
_subDbType(cfg._subDbType),
_fileHeaderContext(ctx._fileHeaderContext, _docTypeName, _baseDir),
@@ -426,9 +428,37 @@ StoreOnlyDocSubDB::reconfigure(const search::LogDocumentStore::Config & config,
_rSummaryMgr->reconfigure(config);
}
+namespace {
+
+constexpr double RETIRED_DEAD_RATIO = 0.5;
+
+struct UpdateConfig : public search::attribute::IAttributeFunctor {
+ void operator()(search::attribute::IAttributeVector &iAttributeVector) override {
+ auto attributeVector = dynamic_cast<search::AttributeVector *>(&iAttributeVector);
+ if (attributeVector != nullptr) {
+ auto cfg = attributeVector->getConfig();
+ cfg.setCompactionStrategy(search::CompactionStrategy(RETIRED_DEAD_RATIO, RETIRED_DEAD_RATIO));
+ attributeVector->update_config(cfg);
+ }
+ }
+};
+
+}
+
void
-StoreOnlyDocSubDB::setBucketStateCalculator(const std::shared_ptr<IBucketStateCalculator> &)
-{
+StoreOnlyDocSubDB::setBucketStateCalculator(const std::shared_ptr<IBucketStateCalculator> & calc)
+{
+ _nodeRetired = calc->nodeRetired();
+ if (isNodeRetired()) {
+ auto cfg = _dms->getConfig();
+ cfg.setCompactionStrategy(search::CompactionStrategy(RETIRED_DEAD_RATIO, RETIRED_DEAD_RATIO));
+ _dms->update_config(cfg);
+
+ auto attrMan = getAttributeManager();
+ if (attrMan) {
+ attrMan->asyncForEachAttribute(std::make_shared<UpdateConfig>());
+ }
+ }
}
proton::IAttributeManager::SP
diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h
index 50e5ffba0e2..3dbf6dfdf07 100644
--- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h
@@ -152,6 +152,7 @@ private:
DocumentMetaStoreFlushTarget::SP _dmsFlushTarget;
std::shared_ptr<ShrinkLidSpaceFlushTarget> _dmsShrinkTarget;
std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit;
+ bool _nodeRetired;
IFlushTargetList getFlushTargets() override;
protected:
@@ -180,9 +181,8 @@ protected:
StoreOnlyFeedView::Context getStoreOnlyFeedViewContext(const DocumentDBConfig &configSnapshot);
StoreOnlyFeedView::PersistentParams getFeedViewPersistentParams();
vespalib::string getSubDbName() const;
-
- void reconfigure(const search::LogDocumentStore::Config & protonConfig,
- const AllocStrategy& alloc_strategy);
+ bool isNodeRetired() const { return _nodeRetired; }
+ void reconfigure(const search::LogDocumentStore::Config & protonConfig, const AllocStrategy& alloc_strategy);
public:
StoreOnlyDocSubDB(const Config &cfg, const Context &ctx);
~StoreOnlyDocSubDB() override;
diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
index deb6639c855..abc8eb679dd 100644
--- a/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
+++ b/searchcore/src/vespa/searchcore/proton/test/mock_attribute_manager.h
@@ -86,8 +86,9 @@ public:
const std::vector<search::AttributeVector *> &getWritableAttributes() const override {
return _writables;
}
- void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor>) const override {
- }
+ void asyncForEachAttribute(std::shared_ptr<IConstAttributeFunctor>) const override { }
+ void asyncForEachAttribute(std::shared_ptr<IAttributeFunctor>) const override { }
+
ExclusiveAttributeReadAccessor::UP getExclusiveReadAccessor(const vespalib::string &) const override {
return ExclusiveAttributeReadAccessor::UP();
}