main: check for large allocations

Large allocations can require cache evictions to be satisfied, and can
therefore induce long latencies. Enable the seastar large allocation
warning so we can hunt them down and fix them.

Message-Id: <20170819135212.25230-1-avi@scylladb.com>
This commit is contained in:
Avi Kivity
2017-08-19 16:52:12 +03:00
committed by Pekka Enberg
parent 318423d50b
commit 5a2439e702
3 changed files with 12 additions and 0 deletions

View File

@@ -777,6 +777,7 @@ public:
val(virtual_dirty_soft_limit, double, 0.6, Used, "Soft limit of virtual dirty memory expressed as a portion of the hard limit") \
val(sstable_summary_ratio, double, 0.0005, Used, "Enforces that 1 byte of summary is written for every N (2000 by default) " \
"bytes written to data file. Value must be between 0 and 1.") \
val(large_memory_allocation_warning_threshold, size_t, size_t(1) << 20, Used, "Warn about memory allocations above this size; set to zero to disable") \
/* done! */
#define _make_value_member(name, type, deflt, status, desc, ...) \

10
main.cc
View File

@@ -53,6 +53,7 @@
#include "core/prometheus.hh"
#include "message/messaging_service.hh"
#include <seastar/net/dns.hh>
#include <seastar/core/memory.hh>
#include "service/cache_hitrate_calculator.hh"
thread_local disk_error_signal_type commit_error;
@@ -270,6 +271,13 @@ verify_adequate_memory_per_shard(bool developer_mode) {
}
}
class memory_threshold_guard {
seastar::memory::scoped_large_allocation_warning_threshold _slawt;
public:
explicit memory_threshold_guard(size_t threshold) : _slawt(threshold) {}
future<> stop() { return make_ready_future<>(); }
};
int main(int ac, char** av) {
int return_value = 0;
try {
@@ -597,6 +605,8 @@ int main(int ac, char** av) {
api::set_server_snitch(ctx).get();
api::set_server_storage_proxy(ctx).get();
api::set_server_load_sstable(ctx).get();
static seastar::sharded<memory_threshold_guard> mtg;
mtg.start(cfg->large_memory_allocation_warning_threshold());
supervisor::notify("initializing migration manager RPC verbs");
service::get_migration_manager().invoke_on_all([] (auto& mm) {
mm.init_messaging_service();

View File

@@ -381,6 +381,7 @@ std::unique_ptr<segment_zone> segment_zone::try_creating_zone()
continue;
}
memory::disable_abort_on_alloc_failure_temporarily no_abort_guard;
seastar::memory::scoped_large_allocation_warning_disable slawd;
auto ptr = aligned_alloc(segment::size, size << segment::size_shift);
if (!ptr) {
continue;