aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2021-01-29 14:29:59 +0000
committerGeir Storli <geirst@verizonmedia.com>2021-01-29 14:34:29 +0000
commit9a676ff3b35353424d9a02a4c09d9dd1bb655f46 (patch)
treecaab73fa5881bb5f2527b22d3138663ba27d48be /storage
parent1341628ee1587fb39703a4fb6e3443286435dca0 (diff)
Wire reporting of attribute resource usage all the way to the cluster controller via the host info API.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/persistence/filestorage/service_layer_host_info_reporter_test.cpp22
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp42
2 files changed, 58 insertions, 6 deletions
diff --git a/storage/src/tests/persistence/filestorage/service_layer_host_info_reporter_test.cpp b/storage/src/tests/persistence/filestorage/service_layer_host_info_reporter_test.cpp
index 86595fb44e8..a54c5c8ccf9 100644
--- a/storage/src/tests/persistence/filestorage/service_layer_host_info_reporter_test.cpp
+++ b/storage/src/tests/persistence/filestorage/service_layer_host_info_reporter_test.cpp
@@ -102,6 +102,28 @@ TEST_F(ServiceLayerHostInfoReporterTest, request_almost_immediate_node_state_as_
EXPECT_EQ(ResourceUsage(0.8, 0.7, {0.1, attr_es_name}, {0.2, attr_mv_name}), get_usage());
}
+TEST_F(ServiceLayerHostInfoReporterTest,
+ first_valid_attribute_enum_store_sample_triggers_immediate_node_state_when_below_slack_diff)
+{
+ // TODO: Assert this is below slack diff when that becomes configurable.
+ constexpr double usage_below_slack_diff = 0.00001;
+ notify(0.0, 0.0, {usage_below_slack_diff, attr_es_name}, {});
+ EXPECT_EQ(1, requested_almost_immediate_replies());
+ EXPECT_EQ(ResourceUsage(0.0, 0.0, {usage_below_slack_diff, attr_es_name}, {}), get_old_usage());
+ EXPECT_EQ(ResourceUsage(0.0, 0.0, {usage_below_slack_diff, attr_es_name}, {}), get_usage());
+}
+
+TEST_F(ServiceLayerHostInfoReporterTest,
+ first_valid_attribute_multi_value_sample_triggers_immediate_node_state_when_below_slack_diff)
+{
+ // TODO: Assert this is below slack diff when that becomes configurable.
+ constexpr double usage_below_slack_diff = 0.00001;
+ notify(0.0, 0.0, {}, {usage_below_slack_diff, attr_mv_name});
+ EXPECT_EQ(1, requested_almost_immediate_replies());
+ EXPECT_EQ(ResourceUsage(0.0, 0.0, {}, {usage_below_slack_diff, attr_mv_name}), get_old_usage());
+ EXPECT_EQ(ResourceUsage(0.0, 0.0, {}, {usage_below_slack_diff, attr_mv_name}), get_usage());
+}
+
TEST_F(ServiceLayerHostInfoReporterTest, json_report_generated)
{
EXPECT_EQ(ResourceUsage(0.0, 0.0), get_slime_usage());
diff --git a/storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp b/storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp
index c78b24bee78..88cdcc2b42f 100644
--- a/storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp
@@ -1,8 +1,13 @@
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "service_layer_host_info_reporter.h"
+#include <vespa/persistence/spi/resource_usage.h>
#include <vespa/storage/common/nodestateupdater.h>
#include <cmath>
+#include <sstream>
+
+#include <vespa/log/log.h>
+LOG_SETUP(".persistence.filestor.service_layer_host_info_reporter");
namespace storage {
@@ -33,13 +38,22 @@ void write_attribute_usage(vespalib::JsonStream& output, const vespalib::string
output << End();
}
-bool want_immediate_report(const spi::ResourceUsage& old_resource_usage, const spi::ResourceUsage& resource_usage)
+bool want_immediate_report(const spi::ResourceUsage& old_usage, const spi::ResourceUsage& new_usage)
{
- auto disk_usage_diff = fabs(resource_usage.get_disk_usage() - old_resource_usage.get_disk_usage());
- auto memory_usage_diff = fabs(resource_usage.get_memory_usage() - old_resource_usage.get_memory_usage());
- auto attribute_enum_store_diff = fabs(resource_usage.get_attribute_enum_store_usage().get_usage() - old_resource_usage.get_attribute_enum_store_usage().get_usage());
- auto attribute_multivalue_diff = fabs(resource_usage.get_attribute_multivalue_usage().get_usage() - old_resource_usage.get_attribute_multivalue_usage().get_usage());
- return (disk_usage_diff > diff_slack || memory_usage_diff > diff_slack || attribute_enum_store_diff > diff_slack || attribute_multivalue_diff > diff_slack);
+ auto disk_usage_diff = fabs(new_usage.get_disk_usage() - old_usage.get_disk_usage());
+ auto memory_usage_diff = fabs(new_usage.get_memory_usage() - old_usage.get_memory_usage());
+ auto enum_store_diff = fabs(new_usage.get_attribute_enum_store_usage().get_usage() - old_usage.get_attribute_enum_store_usage().get_usage());
+ auto multivalue_diff = fabs(new_usage.get_attribute_multivalue_usage().get_usage() - old_usage.get_attribute_multivalue_usage().get_usage());
+ bool enum_store_got_valid = !old_usage.get_attribute_enum_store_usage().valid() &&
+ new_usage.get_attribute_enum_store_usage().valid();
+ bool multivalue_got_valid = !old_usage.get_attribute_multivalue_usage().valid() &&
+ new_usage.get_attribute_multivalue_usage().valid();
+ return ((disk_usage_diff > diff_slack) ||
+ (memory_usage_diff > diff_slack) ||
+ (enum_store_diff > diff_slack) ||
+ (multivalue_diff > diff_slack) ||
+ enum_store_got_valid ||
+ multivalue_got_valid);
}
}
@@ -58,10 +72,25 @@ ServiceLayerHostInfoReporter::~ServiceLayerHostInfoReporter()
spi::ResourceUsageListener::reset(); // detach
}
+namespace {
+
+vespalib::string
+to_string(const spi::ResourceUsage& usage)
+{
+ std::ostringstream oss;
+ oss << usage;
+ return oss.str();
+}
+
+}
+
void
ServiceLayerHostInfoReporter::update_resource_usage(const spi::ResourceUsage& resource_usage)
{
bool immediate_report = want_immediate_report(_old_resource_usage, resource_usage);
+ LOG(debug, "update_resource_usage(): immediate_report=%s, old_usage=%s, new_usage=%s",
+ (immediate_report ? "true" : "false"), to_string(_old_resource_usage).c_str(),
+ to_string(resource_usage).c_str());
if (immediate_report) {
_old_resource_usage = resource_usage;
}
@@ -82,6 +111,7 @@ ServiceLayerHostInfoReporter::report(vespalib::JsonStream& output)
{
std::lock_guard guard(_lock);
auto& usage = get_usage();
+ LOG(debug, "report(): usage=%s", to_string(usage).c_str());
write_usage(output, memory_label, usage.get_memory_usage());
write_usage(output, disk_label, usage.get_disk_usage());
write_attribute_usage(output, attribute_enum_store_label, usage.get_attribute_enum_store_usage());