diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2016-12-15 15:12:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 15:12:49 +0100 |
commit | be638ccbc49e6d52d0b7cd208f7e2a9aae9ebe12 (patch) | |
tree | 7509ba1833c20fdc9f1a867bc170f0448b88324e | |
parent | 72cf874511ed1d18295dcecfc59d151dd35db12c (diff) | |
parent | 9a1f52069961e31d64bec4f2ff47d23eff650db1 (diff) |
Merge pull request #1337 from yahoo/geirst/index-memory-usage-metrics
Geirst/index memory usage metrics
12 files changed, 69 insertions, 37 deletions
diff --git a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp index 29df68b2d17..36cdd7ff89f 100644 --- a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp +++ b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp @@ -61,8 +61,8 @@ TEST("require that the metric proton.diskusage is the sum of the documentDB disk DocumentDBMetricsCollection metrics1("type1", 1); DocumentDBMetricsCollection metrics2("type2", 1); - metrics1.getMetrics().index.diskUsage.addValue(100); - metrics2.getMetrics().index.diskUsage.addValue(1000); + metrics1.getLegacyMetrics().index.diskUsage.addValue(100); + metrics2.getLegacyMetrics().index.diskUsage.addValue(1000); metrics_engine.addDocumentDBMetrics(metrics1); metrics_engine.addDocumentDBMetrics(metrics2); diff --git a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h index a4ef714d09d..6521c98bcdb 100644 --- a/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h +++ b/searchcore/src/vespa/searchcore/proton/index/memoryindexwrapper.h @@ -51,7 +51,7 @@ public: } virtual search::SearchableStats getSearchableStats() const override { return search::SearchableStats() - .memoryUsage(getMemoryUsage().allocatedBytes()) + .memoryUsage(getMemoryUsage()) .docsInMemory(_index.getNumDocs()) .sizeOnDisk(0); } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/attribute_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/attribute_metrics.cpp index 7afc7b0ab0a..e6a03c8df52 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/attribute_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/attribute_metrics.cpp @@ -8,7 +8,7 @@ namespace proton { using Entry = AttributeMetrics::Entry; AttributeMetrics::Entry::Entry(const vespalib::string &attrName) - : metrics::MetricSet("attribute", {{"fieldname", attrName}}, "Metrics for a given attribute vector", nullptr), + : metrics::MetricSet("attribute", {{"field", attrName}}, "Metrics for a given attribute vector", nullptr), memoryUsage(this) { } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_metrics_collection.h b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_metrics_collection.h index 20e72a23edf..3a2b0ff8633 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_metrics_collection.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_metrics_collection.h @@ -21,7 +21,7 @@ public: _taggedMetrics(docTypeName) { } - LegacyDocumentDBMetrics &getMetrics() { return _metrics; } + LegacyDocumentDBMetrics &getLegacyMetrics() { return _metrics; } DocumentDBTaggedMetrics &getTaggedMetrics() { return _taggedMetrics; } }; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp index 68580d90974..213c869a8e4 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp @@ -76,10 +76,17 @@ DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::ResourceUsageMe { } +DocumentDBTaggedMetrics::IndexMetrics::IndexMetrics(MetricSet *parent) + : MetricSet("index", "", "Index metrics (memory and disk) for this document db", parent), + memoryUsage(this) +{ +} + DocumentDBTaggedMetrics::DocumentDBTaggedMetrics(const vespalib::string &docTypeName) : MetricSet("documentdb", {{"documenttype", docTypeName}}, "Document DB metrics", nullptr), job(this), attribute(this), + index(this), ready("ready", this), notReady("notready", this), removed("removed", this) diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h index 39f4733f66c..323d0766e6f 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h @@ -76,8 +76,16 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet AttributeMetrics(metrics::MetricSet *parent); }; + struct IndexMetrics : metrics::MetricSet + { + MemoryUsageMetrics memoryUsage; + + IndexMetrics(metrics::MetricSet *parent); + }; + JobMetrics job; AttributeMetrics attribute; + IndexMetrics index; SubDBMetrics ready; SubDBMetrics notReady; SubDBMetrics removed; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp index 59d33675d34..23daf44d98a 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp @@ -112,7 +112,7 @@ void MetricsEngine::addDocumentDBMetrics(DocumentDBMetricsCollection &child) { metrics::MetricLockGuard guard(_manager->getMetricLock()); - addLegacyDocumentDBMetrics(_legacyRoot, child.getMetrics()); + addLegacyDocumentDBMetrics(_legacyRoot, child.getLegacyMetrics()); _root.registerMetric(child.getTaggedMetrics()); } @@ -121,7 +121,7 @@ void MetricsEngine::removeDocumentDBMetrics(DocumentDBMetricsCollection &child) { metrics::MetricLockGuard guard(_manager->getMetricLock()); - removeLegacyDocumentDBMetrics(_legacyRoot, child.getMetrics()); + removeLegacyDocumentDBMetrics(_legacyRoot, child.getLegacyMetrics()); _root.unregisterMetric(child.getTaggedMetrics()); } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index b21d6c1eba8..86a2f3460ee 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -132,7 +132,7 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, _feedHandler(_writeService, tlsSpec, docTypeName, - getMetricsCollection().getMetrics().feed, + getMetricsCollection().getLegacyMetrics().feed, _state, *this, _writeFilter, @@ -559,7 +559,7 @@ DocumentDB::close() // The attributes in the ready sub db is also the total set of attributes. DocumentDBTaggedMetrics &metrics = getMetricsCollection().getTaggedMetrics(); - LegacyDocumentDBMetrics &legacyMetrics = getMetricsCollection().getMetrics(); + LegacyDocumentDBMetrics &legacyMetrics = getMetricsCollection().getLegacyMetrics(); AttributeMetricsCollection ready(metrics.ready.attributes, legacyMetrics.ready.attributes); AttributeMetricsCollection notReady(metrics.notReady.attributes, legacyMetrics.notReady.attributes); _metricsWireService.cleanAttributes(ready, &legacyMetrics.attributes); @@ -1245,12 +1245,16 @@ DocumentDB::getIndexManagerFactory(const vespalib::stringref &name) const namespace { void -updateIndexMetrics(LegacyDocumentDBMetrics::IndexMetrics &metrics, +updateIndexMetrics(DocumentDBMetricsCollection &metrics, const search::SearchableStats &stats) { - metrics.memoryUsage.set(stats.memoryUsage()); - metrics.docsInMemory.set(stats.docsInMemory()); - metrics.diskUsage.set(stats.sizeOnDisk()); + DocumentDBTaggedMetrics::IndexMetrics &indexMetrics = metrics.getTaggedMetrics().index; + indexMetrics.memoryUsage.update(stats.memoryUsage()); + + LegacyDocumentDBMetrics::IndexMetrics &legacyIndexMetrics = metrics.getLegacyMetrics().index; + legacyIndexMetrics.memoryUsage.set(stats.memoryUsage().allocatedBytes()); + legacyIndexMetrics.docsInMemory.set(stats.docsInMemory()); + legacyIndexMetrics.diskUsage.set(stats.sizeOnDisk()); } struct TempAttributeMetric @@ -1362,9 +1366,9 @@ updateAttributeMetrics(DocumentDBMetricsCollection &metrics, TempAttributeMetrics notReadyMetrics; fillTempAttributeMetrics(totalMetrics, readyMetrics, notReadyMetrics, subDbs); - updateLegacyAttributeMetrics(metrics.getMetrics().attributes, totalMetrics); - updateLegacyAttributeMetrics(metrics.getMetrics().ready.attributes, readyMetrics); - updateLegacyAttributeMetrics(metrics.getMetrics().notReady.attributes, notReadyMetrics); + updateLegacyAttributeMetrics(metrics.getLegacyMetrics().attributes, totalMetrics); + updateLegacyAttributeMetrics(metrics.getLegacyMetrics().ready.attributes, readyMetrics); + updateLegacyAttributeMetrics(metrics.getLegacyMetrics().notReady.attributes, notReadyMetrics); updateAttributeMetrics(metrics.getTaggedMetrics().ready.attributes, readyMetrics); updateAttributeMetrics(metrics.getTaggedMetrics().notReady.attributes, notReadyMetrics); @@ -1455,7 +1459,8 @@ updateLidSpaceMetrics(MetricSetType &metrics, void DocumentDB::updateMetrics(DocumentDBMetricsCollection &metrics) { - updateLegacyMetrics(metrics.getMetrics()); + updateLegacyMetrics(metrics.getLegacyMetrics()); + updateIndexMetrics(metrics, _subDBs.getReadySubDB()->getSearchableStats()); updateAttributeMetrics(metrics, _subDBs); updateMetrics(metrics.getTaggedMetrics()); } @@ -1463,8 +1468,6 @@ DocumentDB::updateMetrics(DocumentDBMetricsCollection &metrics) void DocumentDB::updateLegacyMetrics(LegacyDocumentDBMetrics &metrics) { - updateIndexMetrics(metrics.index, - _subDBs.getReadySubDB()->getSearchableStats()); updateMatchingMetrics(metrics.matching, *_subDBs.getReadySubDB()); metrics.executor.update(_writeService.getMasterExecutor().getStats()); metrics.indexExecutor.update(_writeService.getIndexExecutor().getStats()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index dfb85ac47f1..06d6162baee 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -65,7 +65,7 @@ DocumentSubDBCollection::DocumentSubDBCollection( summaryExecutor, _bucketDB, *_bucketDBHandler, - metrics.getMetrics(), + metrics.getLegacyMetrics(), configLock, hwInfo); _subDBs.push_back @@ -85,8 +85,8 @@ DocumentSubDBCollection::DocumentSubDBCollection( SearchableDocSubDB::Context(FastAccessDocSubDB::Context (context, AttributeMetricsCollection(metrics.getTaggedMetrics().ready.attributes, - metrics.getMetrics().ready.attributes), - &metrics.getMetrics().attributes, + metrics.getLegacyMetrics().ready.attributes), + &metrics.getLegacyMetrics().attributes, metricsWireService), queryLimiter, clock, @@ -114,7 +114,7 @@ DocumentSubDBCollection::DocumentSubDBCollection( true), FastAccessDocSubDB::Context(context, AttributeMetricsCollection(metrics.getTaggedMetrics().notReady.attributes, - metrics.getMetrics().notReady.attributes), + metrics.getLegacyMetrics().notReady.attributes), NULL, metricsWireService))); } diff --git a/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp b/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp index 959f5ccdc59..7920c1650cb 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/index_manager_explorer.cpp @@ -18,7 +18,8 @@ namespace searchcorespi { namespace { -void insertDiskIndex(Cursor &arrayCursor, const DiskIndexStats &diskIndex) +void +insertDiskIndex(Cursor &arrayCursor, const DiskIndexStats &diskIndex) { Cursor &diskIndexCursor = arrayCursor.addObject(); const SearchableStats &sstats = diskIndex.getSearchableStats(); @@ -27,13 +28,24 @@ void insertDiskIndex(Cursor &arrayCursor, const DiskIndexStats &diskIndex) diskIndexCursor.setLong("sizeOnDisk", sstats.sizeOnDisk()); } -void insertMemoryIndex(Cursor &arrayCursor, const MemoryIndexStats &memoryIndex) +void +insertMemoryUsage(Cursor &object, const search::MemoryUsage &usage) +{ + Cursor &memory = object.setObject("memoryUsage"); + memory.setLong("allocatedBytes", usage.allocatedBytes()); + memory.setLong("usedBytes", usage.usedBytes()); + memory.setLong("deadBytes", usage.deadBytes()); + memory.setLong("onHoldBytes", usage.allocatedBytesOnHold()); +} + +void +insertMemoryIndex(Cursor &arrayCursor, const MemoryIndexStats &memoryIndex) { Cursor &memoryIndexCursor = arrayCursor.addObject(); const SearchableStats &sstats = memoryIndex.getSearchableStats(); memoryIndexCursor.setLong("serialNum", memoryIndex.getSerialNum()); memoryIndexCursor.setLong("docsInMemory", sstats.docsInMemory()); - memoryIndexCursor.setLong("memoryUsage", sstats.memoryUsage()); + insertMemoryUsage(memoryIndexCursor, sstats.memoryUsage()); } } diff --git a/searchlib/src/tests/util/searchable_stats/searchable_stats_test.cpp b/searchlib/src/tests/util/searchable_stats/searchable_stats_test.cpp index 83aba794824..d5c77fb28e4 100644 --- a/searchlib/src/tests/util/searchable_stats/searchable_stats_test.cpp +++ b/searchlib/src/tests/util/searchable_stats/searchable_stats_test.cpp @@ -18,21 +18,21 @@ Test::Main() TEST_INIT("searchable_stats_test"); { SearchableStats stats; - EXPECT_EQUAL(0u, stats.memoryUsage()); + EXPECT_EQUAL(0u, stats.memoryUsage().allocatedBytes()); EXPECT_EQUAL(0u, stats.docsInMemory()); EXPECT_EQUAL(0u, stats.sizeOnDisk()); { SearchableStats rhs; - EXPECT_EQUAL(&rhs.memoryUsage(100), &rhs); + EXPECT_EQUAL(&rhs.memoryUsage(MemoryUsage(100,0,0,0)), &rhs); EXPECT_EQUAL(&rhs.docsInMemory(10), &rhs); EXPECT_EQUAL(&rhs.sizeOnDisk(1000), &rhs); EXPECT_EQUAL(&stats.add(rhs), &stats); } - EXPECT_EQUAL(100u, stats.memoryUsage()); + EXPECT_EQUAL(100u, stats.memoryUsage().allocatedBytes()); EXPECT_EQUAL(10u, stats.docsInMemory()); EXPECT_EQUAL(1000u, stats.sizeOnDisk()); - EXPECT_EQUAL(&stats.add(SearchableStats().memoryUsage(100).docsInMemory(10).sizeOnDisk(1000)), &stats); - EXPECT_EQUAL(200u, stats.memoryUsage()); + EXPECT_EQUAL(&stats.add(SearchableStats().memoryUsage(MemoryUsage(100,0,0,0)).docsInMemory(10).sizeOnDisk(1000)), &stats); + EXPECT_EQUAL(200u, stats.memoryUsage().allocatedBytes()); EXPECT_EQUAL(20u, stats.docsInMemory()); EXPECT_EQUAL(2000u, stats.sizeOnDisk()); } diff --git a/searchlib/src/vespa/searchlib/util/searchable_stats.h b/searchlib/src/vespa/searchlib/util/searchable_stats.h index a7d5764de7c..a87c15990f0 100644 --- a/searchlib/src/vespa/searchlib/util/searchable_stats.h +++ b/searchlib/src/vespa/searchlib/util/searchable_stats.h @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "memoryusage.h" + namespace search { /** @@ -11,17 +13,17 @@ namespace search { class SearchableStats { private: - size_t _memoryUsage; + MemoryUsage _memoryUsage; size_t _docsInMemory; size_t _sizeOnDisk; public: - SearchableStats() : _memoryUsage(0), _docsInMemory(0), _sizeOnDisk(0) {} - SearchableStats &memoryUsage(size_t value) { - _memoryUsage = value; + SearchableStats() : _memoryUsage(), _docsInMemory(0), _sizeOnDisk(0) {} + SearchableStats &memoryUsage(const MemoryUsage &usage) { + _memoryUsage = usage; return *this; } - size_t memoryUsage() const { return _memoryUsage; } + const MemoryUsage &memoryUsage() const { return _memoryUsage; } SearchableStats &docsInMemory(size_t value) { _docsInMemory = value; return *this; @@ -33,7 +35,7 @@ public: } size_t sizeOnDisk() const { return _sizeOnDisk; } SearchableStats &add(const SearchableStats &rhs) { - _memoryUsage += rhs._memoryUsage; + _memoryUsage.merge(rhs._memoryUsage); _docsInMemory += rhs._docsInMemory; _sizeOnDisk += rhs._sizeOnDisk; return *this; |