mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 00:50:35 +00:00
Merge seastar upstream
This commit is contained in:
@@ -88,6 +88,7 @@ class page_list;
|
||||
static thread_local uint64_t g_allocs;
|
||||
static thread_local uint64_t g_frees;
|
||||
static thread_local uint64_t g_cross_cpu_frees;
|
||||
static thread_local uint64_t g_reclaims;
|
||||
|
||||
using std::experimental::optional;
|
||||
|
||||
@@ -653,6 +654,7 @@ void cpu_pages::resize(size_t new_size, allocate_system_memory_fn alloc_memory)
|
||||
void cpu_pages::reclaim() {
|
||||
current_min_free_pages = 0;
|
||||
reclaim_hook([this] {
|
||||
++g_reclaims;
|
||||
for (auto&& r : reclaimers) {
|
||||
r->do_reclaim();
|
||||
}
|
||||
@@ -871,7 +873,8 @@ void configure(std::vector<resource::memory> m,
|
||||
}
|
||||
|
||||
statistics stats() {
|
||||
return statistics{g_allocs, g_frees, g_cross_cpu_frees};
|
||||
return statistics{g_allocs, g_frees, g_cross_cpu_frees,
|
||||
cpu_mem.nr_free_pages * page_size, g_reclaims};
|
||||
}
|
||||
|
||||
bool drain_cross_cpu_freelist() {
|
||||
@@ -1162,7 +1165,7 @@ void configure(std::vector<resource::memory> m, std::experimental::optional<std:
|
||||
}
|
||||
|
||||
statistics stats() {
|
||||
return statistics{0, 0, 0};
|
||||
return statistics{0, 0, 0, 0, 0};
|
||||
}
|
||||
|
||||
bool drain_cross_cpu_freelist() {
|
||||
|
||||
@@ -114,9 +114,13 @@ class statistics {
|
||||
uint64_t _mallocs;
|
||||
uint64_t _frees;
|
||||
uint64_t _cross_cpu_frees;
|
||||
size_t _free_memory;
|
||||
uint64_t _reclaims;
|
||||
private:
|
||||
statistics(uint64_t mallocs, uint64_t frees, uint64_t cross_cpu_frees)
|
||||
: _mallocs(mallocs), _frees(frees), _cross_cpu_frees(cross_cpu_frees) {}
|
||||
statistics(uint64_t mallocs, uint64_t frees, uint64_t cross_cpu_frees,
|
||||
uint64_t free_memory, uint64_t reclaims)
|
||||
: _mallocs(mallocs), _frees(frees), _cross_cpu_frees(cross_cpu_frees)
|
||||
, _free_memory(free_memory), _reclaims(reclaims) {}
|
||||
public:
|
||||
/// Total number of memory allocations calls since the system was started.
|
||||
uint64_t mallocs() const { return _mallocs; }
|
||||
@@ -127,6 +131,10 @@ public:
|
||||
uint64_t cross_cpu_frees() const { return _cross_cpu_frees; }
|
||||
/// Total number of objects which were allocated but not freed.
|
||||
size_t live_objects() const { return mallocs() - frees(); }
|
||||
/// Total free memory (in bytes)
|
||||
size_t free_memory() const { return _free_memory; }
|
||||
/// Number of reclaims performed due to low memory
|
||||
uint64_t reclaims() const { return _reclaims; }
|
||||
friend statistics stats();
|
||||
};
|
||||
|
||||
|
||||
@@ -999,6 +999,20 @@ reactor::register_collectd_metrics() {
|
||||
scollectd::make_typed(scollectd::data_type::GAUGE,
|
||||
[] { return memory::stats().live_objects(); })
|
||||
),
|
||||
scollectd::add_polled_metric(
|
||||
scollectd::type_instance_id("memory",
|
||||
scollectd::per_cpu_plugin_instance,
|
||||
"memory", "free_memory"),
|
||||
scollectd::make_typed(scollectd::data_type::GAUGE,
|
||||
[] { return memory::stats().free_memory(); })
|
||||
),
|
||||
scollectd::add_polled_metric(
|
||||
scollectd::type_instance_id("memory",
|
||||
scollectd::per_cpu_plugin_instance,
|
||||
"total_operations", "reclaims"),
|
||||
scollectd::make_typed(scollectd::data_type::DERIVE,
|
||||
[] { return memory::stats().reclaims(); })
|
||||
),
|
||||
} };
|
||||
}
|
||||
|
||||
|
||||
29
rpc/rpc.hh
29
rpc/rpc.hh
@@ -28,6 +28,7 @@
|
||||
#include "core/reactor.hh"
|
||||
#include "core/iostream.hh"
|
||||
#include "core/shared_ptr.hh"
|
||||
#include "rpc/rpc_types.hh"
|
||||
|
||||
namespace rpc {
|
||||
|
||||
@@ -45,10 +46,6 @@ struct SerializerConcept {
|
||||
future<> operator()(input_stream<char>& in, sstring& v);
|
||||
};
|
||||
|
||||
struct client_info {
|
||||
socket_address addr;
|
||||
};
|
||||
|
||||
// MsgType is a type that holds type of a message. The type should be hashable
|
||||
// and serializable. It is preferable to use enum for message types, but
|
||||
// do not forget to provide hash function for it
|
||||
@@ -124,15 +121,6 @@ public:
|
||||
virtual ~reply_handler_base() {};
|
||||
};
|
||||
public:
|
||||
struct stats {
|
||||
using counter_type = uint64_t;
|
||||
counter_type replied = 0;
|
||||
counter_type pending = 0;
|
||||
counter_type exception_received = 0;
|
||||
counter_type sent_messages = 0;
|
||||
counter_type wait_reply = 0;
|
||||
};
|
||||
|
||||
template<typename Reply, typename Func>
|
||||
struct reply_handler final : reply_handler_base {
|
||||
Func func;
|
||||
@@ -199,21 +187,6 @@ private:
|
||||
_handlers.emplace(t, std::move(handler));
|
||||
}
|
||||
};
|
||||
|
||||
class error : public std::runtime_error {
|
||||
public:
|
||||
error(const std::string& msg) : std::runtime_error(msg) {}
|
||||
};
|
||||
|
||||
class closed_error : public error {
|
||||
public:
|
||||
closed_error() : error("connection is closed") {}
|
||||
};
|
||||
|
||||
struct no_wait_type {};
|
||||
|
||||
// return this from a callback if client does not want to waiting for a reply
|
||||
extern no_wait_type no_wait;
|
||||
}
|
||||
|
||||
#include "rpc_impl.hh"
|
||||
|
||||
59
rpc/rpc_types.hh
Normal file
59
rpc/rpc_types.hh
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is open source software, licensed to you under the terms
|
||||
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
|
||||
* distributed with this work for additional information regarding copyright
|
||||
* ownership. You may not use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2015 Cloudius Systems, Ltd.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "net/api.hh"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace rpc {
|
||||
|
||||
struct stats {
|
||||
using counter_type = uint64_t;
|
||||
counter_type replied = 0;
|
||||
counter_type pending = 0;
|
||||
counter_type exception_received = 0;
|
||||
counter_type sent_messages = 0;
|
||||
counter_type wait_reply = 0;
|
||||
};
|
||||
|
||||
|
||||
struct client_info {
|
||||
socket_address addr;
|
||||
};
|
||||
|
||||
class error : public std::runtime_error {
|
||||
public:
|
||||
error(const std::string& msg) : std::runtime_error(msg) {}
|
||||
};
|
||||
|
||||
class closed_error : public error {
|
||||
public:
|
||||
closed_error() : error("connection is closed") {}
|
||||
};
|
||||
|
||||
struct no_wait_type {};
|
||||
|
||||
// return this from a callback if client does not want to waiting for a reply
|
||||
extern no_wait_type no_wait;
|
||||
|
||||
} // namespace rpc
|
||||
Reference in New Issue
Block a user