mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
chore(server): Fix clang warnings and errors (#290)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
b8d791961e
commit
4522f2fdd1
9 changed files with 41 additions and 16 deletions
2
helio
2
helio
|
@ -1 +1 @@
|
|||
Subproject commit 0f87cb9c5e9e846c721eb6c93603d6fdc14223bd
|
||||
Subproject commit 723774a0248102f97c8b0e71b5078025386c3ac1
|
|
@ -396,10 +396,11 @@ void Connection::ConnectionFlow(FiberSocketBase* peer) {
|
|||
error_code ec2 = peer->Write(::io::Buffer(sv));
|
||||
if (ec2) {
|
||||
LOG(WARNING) << "Error " << ec2;
|
||||
ec = ec;
|
||||
ec = ec2;
|
||||
}
|
||||
}
|
||||
peer->Shutdown(SHUT_RDWR);
|
||||
error_code ec2 = peer->Shutdown(SHUT_RDWR);
|
||||
LOG_IF(WARNING, ec2) << "Could not shutdown socket " << ec2;
|
||||
}
|
||||
|
||||
if (ec && !FiberSocketBase::IsConnClosed(ec)) {
|
||||
|
|
|
@ -10,12 +10,14 @@ endif()
|
|||
|
||||
add_library(redis_lib crc64.c crcspeed.c debug.c dict.c intset.c
|
||||
listpack.c mt19937-64.c object.c lzf_c.c lzf_d.c sds.c
|
||||
quicklist.c rax.c redis_aux.c siphash.c t_hash.c t_stream.c t_zset.c
|
||||
quicklist.c rax.c redis_aux.c siphash.c t_hash.c t_stream.c t_zset.c
|
||||
util.c ziplist.c ${ZMALLOC_SRC})
|
||||
|
||||
cxx_link(redis_lib ${ZMALLOC_DEPS})
|
||||
|
||||
target_compile_options(redis_lib PRIVATE -Wno-maybe-uninitialized)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
target_compile_options(redis_lib PRIVATE -Wno-maybe-uninitialized)
|
||||
endif()
|
||||
|
||||
if (REDIS_ZMALLOC_MI)
|
||||
target_compile_definitions(redis_lib PUBLIC USE_ZMALLOC_MI)
|
||||
|
|
|
@ -10,7 +10,7 @@ add_library(dragonfly_lib channel_slice.cc command_registry.cc
|
|||
config_flags.cc conn_context.cc debugcmd.cc dflycmd.cc
|
||||
generic_family.cc hset_family.cc json_family.cc
|
||||
list_family.cc main_service.cc rdb_load.cc rdb_save.cc replica.cc
|
||||
snapshot.cc script_mgr.cc server_family.cc
|
||||
snapshot.cc script_mgr.cc server_family.cc malloc_stats.cc
|
||||
set_family.cc stream_family.cc string_family.cc
|
||||
zset_family.cc version.cc)
|
||||
|
||||
|
|
|
@ -122,6 +122,9 @@ extern std::atomic_uint64_t used_mem_peak;
|
|||
extern std::atomic_uint64_t used_mem_current;
|
||||
extern size_t max_memory_limit;
|
||||
|
||||
// malloc memory stats.
|
||||
int64_t GetMallocCurrentCommitted();
|
||||
|
||||
// version 5.11 maps to 511 etc.
|
||||
// set upon server start.
|
||||
extern unsigned kernel_version;
|
||||
|
|
|
@ -251,7 +251,7 @@ OpStatus BPopper::Run(Transaction* t, unsigned msec) {
|
|||
// We got here
|
||||
if (!result) {
|
||||
// cleanups, locks removal etc.
|
||||
auto cb = [this](Transaction* t, EngineShard* shard) { return OpStatus::OK; };
|
||||
auto cb = [](Transaction* t, EngineShard* shard) { return OpStatus::OK; };
|
||||
t->Execute(std::move(cb), true);
|
||||
|
||||
return result.status();
|
||||
|
|
|
@ -953,10 +953,11 @@ bool CheckWatchedKeyExpiry(ConnectionContext* cntx, const CommandRegistry& regis
|
|||
}
|
||||
|
||||
atomic_uint32_t watch_exist_count{0};
|
||||
auto cb = [&watch_exist_count, &exec_info](Transaction* t, EngineShard* shard) {
|
||||
auto cb = [&watch_exist_count](Transaction* t, EngineShard* shard) {
|
||||
ArgSlice args = t->ShardArgsInShard(shard->shard_id());
|
||||
auto res = GenericFamily::OpExists(t->GetOpArgs(shard), args);
|
||||
watch_exist_count.fetch_add(res.value_or(0), memory_order_relaxed);
|
||||
|
||||
return OpStatus::OK;
|
||||
};
|
||||
|
||||
|
|
23
src/server/malloc_stats.cc
Normal file
23
src/server/malloc_stats.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2022, Roman Gershman. All rights reserved.
|
||||
// See LICENSE for licensing terms.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
#include <mimalloc.h>
|
||||
#include <mimalloc-types.h>
|
||||
|
||||
// clang-format on
|
||||
|
||||
// This is an internal struct in mimalloc.
|
||||
// To declare it, we must include mimalloc-types.h which is an internal header in the lib.
|
||||
// Being such it does not interract well with some other c++ headers, therefore we
|
||||
// use a clean cc file to extract data from this record.
|
||||
extern "C" mi_stats_t _mi_stats_main;
|
||||
|
||||
namespace dfly {
|
||||
|
||||
int64_t GetMallocCurrentCommitted() {
|
||||
return _mi_stats_main.committed.current;
|
||||
}
|
||||
|
||||
} // namespace dfly
|
|
@ -8,7 +8,7 @@
|
|||
#include <absl/random/random.h> // for master_id_ generation.
|
||||
#include <absl/strings/match.h>
|
||||
#include <absl/strings/str_join.h>
|
||||
#include <mimalloc-types.h>
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <chrono>
|
||||
|
@ -56,8 +56,6 @@ ABSL_DECLARE_FLAG(uint32_t, port);
|
|||
ABSL_DECLARE_FLAG(bool, cache_mode);
|
||||
ABSL_DECLARE_FLAG(uint32_t, hz);
|
||||
|
||||
extern "C" mi_stats_t _mi_stats_main;
|
||||
|
||||
namespace dfly {
|
||||
|
||||
namespace fibers = ::boost::fibers;
|
||||
|
@ -172,9 +170,6 @@ class RdbSnapshot {
|
|||
}
|
||||
|
||||
private:
|
||||
// whether this RdbSnapshot captures only a single shard,
|
||||
// false for legacy - rdb snapshot that captures
|
||||
bool single_shard_;
|
||||
bool started_ = false;
|
||||
|
||||
unique_ptr<uring::LinuxFile> file_;
|
||||
|
@ -561,7 +556,7 @@ void PrintPrometheusMetrics(const Metrics& m, StringResponse* resp) {
|
|||
&resp->body());
|
||||
AppendMetricWithoutLabels("memory_used_peak_bytes", "", used_mem_peak.load(memory_order_relaxed),
|
||||
MetricType::GAUGE, &resp->body());
|
||||
AppendMetricWithoutLabels("comitted_memory", "", _mi_stats_main.committed.current,
|
||||
AppendMetricWithoutLabels("comitted_memory", "", GetMallocCurrentCommitted(),
|
||||
MetricType::GAUGE, &resp->body());
|
||||
AppendMetricWithoutLabels("memory_max_bytes", "", max_memory_limit, MetricType::GAUGE,
|
||||
&resp->body());
|
||||
|
@ -1116,7 +1111,7 @@ void ServerFamily::Info(CmdArgList args, ConnectionContext* cntx) {
|
|||
append("used_memory_human", HumanReadableNumBytes(m.heap_used_bytes));
|
||||
append("used_memory_peak", used_mem_peak.load(memory_order_relaxed));
|
||||
|
||||
append("comitted_memory", _mi_stats_main.committed.current);
|
||||
append("comitted_memory", GetMallocCurrentCommitted());
|
||||
|
||||
if (sdata_res.has_value()) {
|
||||
append("used_memory_rss", sdata_res->vm_rss);
|
||||
|
|
Loading…
Reference in a new issue