diff --git a/core/memory.cc b/core/memory.cc index d60ad295fd..5a4532f957 100644 --- a/core/memory.cc +++ b/core/memory.cc @@ -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 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 m, std::experimental::optional operator()(input_stream& 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 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" diff --git a/rpc/rpc_types.hh b/rpc/rpc_types.hh new file mode 100644 index 0000000000..41c38b9401 --- /dev/null +++ b/rpc/rpc_types.hh @@ -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 +#include + +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