summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-04-30 10:16:29 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-04-30 10:16:29 +0000
commitdd219bb6ce23d890bab5c13b91585b311f1a1b40 (patch)
tree36770e011808b01a194637c17782e9df17ab4279 /searchcore
parent485c6a41c13d4a386da63e082c185c81da798d21 (diff)
If we enter blocking state we should sample every second in order to quickly detect when we are out of it.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp14
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h5
2 files changed, 14 insertions, 5 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
index 10ee33df019..a3fb1244c45 100644
--- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
@@ -13,6 +13,7 @@ DiskMemUsageSampler::DiskMemUsageSampler(const std::string &path_in, const Confi
: _filter(config.hwInfo),
_path(path_in),
_sampleInterval(60s),
+ _lastSampleTime(vespalib::steady_clock::now()),
_periodicTimer()
{
setConfig(config);
@@ -30,10 +31,17 @@ DiskMemUsageSampler::setConfig(const Config &config)
_filter.setConfig(config.filterConfig);
_sampleInterval = config.sampleInterval;
sampleUsage();
+ _lastSampleTime = vespalib::steady_clock::now();
_periodicTimer = std::make_unique<vespalib::ScheduledExecutor>();
- _periodicTimer->scheduleAtFixedRate(makeLambdaTask([this]()
- { sampleUsage(); }),
- _sampleInterval, _sampleInterval);
+ vespalib::duration maxInterval = std::min(vespalib::duration(1s), _sampleInterval);
+ _periodicTimer->scheduleAtFixedRate(makeLambdaTask([this]() {
+ if (_filter.acceptWriteOperation() && (vespalib::steady_clock::now() < (_lastSampleTime + _sampleInterval))) {
+ return;
+ }
+ sampleUsage();
+ _lastSampleTime = vespalib::steady_clock::now();
+ }),
+ maxInterval, maxInterval);
}
void
diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h
index ba204cc1d0f..bbfc95ff82c 100644
--- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h
+++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.h
@@ -13,9 +13,10 @@ namespace proton {
* Class to sample disk and memory usage used for filtering write operations.
*/
class DiskMemUsageSampler {
- DiskMemUsageFilter _filter;
+ DiskMemUsageFilter _filter;
std::filesystem::path _path;
- vespalib::duration _sampleInterval;
+ vespalib::duration _sampleInterval;
+ vespalib::steady_time _lastSampleTime;
std::unique_ptr<vespalib::ScheduledExecutor> _periodicTimer;
void sampleUsage();