mirror of
https://github.com/dragonflydb/dragonfly
synced 2024-11-21 23:19:53 +00:00
chore: Add 'memory arena show' command (#3298)
* chore: Add 'memory arena show' command Its output goes to stdout. --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
5d4b969bee
commit
b61c722f84
@ -100,9 +100,12 @@ void MemoryCmd::Run(CmdArgList args) {
|
||||
" Shows breakdown of memory.",
|
||||
"MALLOC-STATS",
|
||||
" Show global malloc stats as provided by allocator libraries",
|
||||
"ARENA [BACKING] [thread-id]",
|
||||
"ARENA BACKING] [thread-id]",
|
||||
" Show mimalloc arena stats for a heap residing in specified thread-id. 0 by default.",
|
||||
" If BACKING is specified, show stats for the backing heap.",
|
||||
"ARENA SHOW",
|
||||
" Prints the arena summary report for the entire process.",
|
||||
" Requires MIMALLOC_VERBOSE=1 environment to be set. The output goes to stdout",
|
||||
"USAGE <key>",
|
||||
" Show memory usage of a key.",
|
||||
"DECOMMIT",
|
||||
@ -321,20 +324,32 @@ void MemoryCmd::MallocStats() {
|
||||
void MemoryCmd::ArenaStats(CmdArgList args) {
|
||||
uint32_t tid = 0;
|
||||
bool backing = false;
|
||||
bool show_arenas = false;
|
||||
if (args.size() >= 2) {
|
||||
ToUpper(&args[1]);
|
||||
|
||||
unsigned tid_indx = 1;
|
||||
if (ArgS(args, tid_indx) == "BACKING") {
|
||||
++tid_indx;
|
||||
backing = true;
|
||||
}
|
||||
if (ArgS(args, 1) == "SHOW") {
|
||||
if (args.size() != 2)
|
||||
return cntx_->SendError(kSyntaxErr, kSyntaxErrType);
|
||||
show_arenas = true;
|
||||
} else {
|
||||
unsigned tid_indx = 1;
|
||||
|
||||
if (args.size() > tid_indx && !absl::SimpleAtoi(ArgS(args, tid_indx), &tid)) {
|
||||
return cntx_->SendError(kInvalidIntErr);
|
||||
if (ArgS(args, tid_indx) == "BACKING") {
|
||||
++tid_indx;
|
||||
backing = true;
|
||||
}
|
||||
if (args.size() > tid_indx && !absl::SimpleAtoi(ArgS(args, tid_indx), &tid)) {
|
||||
return cntx_->SendError(kInvalidIntErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (show_arenas) {
|
||||
mi_debug_show_arenas(true, true, true);
|
||||
return cntx_->reply_builder()->SendOk();
|
||||
}
|
||||
|
||||
if (backing && tid >= shard_set->pool()->size()) {
|
||||
return cntx_->SendError(
|
||||
absl::StrCat("Thread id must be less than ", shard_set->pool()->size()));
|
||||
|
@ -181,7 +181,7 @@ void Transaction::InitGlobal() {
|
||||
void Transaction::BuildShardIndex(const KeyIndex& key_index, std::vector<PerShardCache>* out) {
|
||||
auto& shard_index = *out;
|
||||
|
||||
auto add = [this, &shard_index](uint32_t sid, uint32_t b, uint32_t e) {
|
||||
auto add = [&shard_index](uint32_t sid, uint32_t b, uint32_t e) {
|
||||
auto& slices = shard_index[sid].slices;
|
||||
if (!slices.empty() && slices.back().second == b) {
|
||||
slices.back().second = e;
|
||||
|
Loading…
Reference in New Issue
Block a user