Skip to content

Commit

Permalink
fix(jemalloc): enlarge the buffer size to dump jemalloc stats (apache…
Browse files Browse the repository at this point in the history
…#1636)

apache#1635

- Enlarge the buffer size to dump jemalloc stats
- Improve the jemalloc unit tests
  • Loading branch information
acelyc111 authored Oct 12, 2023
1 parent 4cb6828 commit 0ccf110
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/utils/je_ctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const char *je_stats_type_to_opts(je_stats_type type)
size_t je_stats_type_to_default_buf_sz(je_stats_type type)
{
static const size_t buf_sz_map[] = {
2 * 1024, 4 * 1024, 1024 * 1024, 2 * 1024 * 1024,
2 * 1024, 4 * 1024, 8 * 1024 * 1024, 8 * 1024 * 1024,
};

RETURN_ARRAY_ELEM_BY_ENUM_TYPE(type, buf_sz_map);
Expand Down
33 changes: 17 additions & 16 deletions src/utils/test/je_ctl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

#ifdef DSN_USE_JEMALLOC

#include "utils/je_ctl.h"

#include <gtest/gtest.h>

#include "utils/je_ctl.h"
#include "utils/test_macros.h"

namespace dsn {

namespace {
Expand Down Expand Up @@ -53,52 +54,52 @@ void check_configs_marks(const std::string &stats)
void check_arena_marks(const std::string &stats)
{
// Marks for merged arenas.
ASSERT_NE(stats.find("Merged arenas stats:"), std::string::npos);
ASSERT_NE(stats.find("Merged arenas stats:"), std::string::npos) << stats;

// Marks for each arena.
ASSERT_NE(stats.find("arenas[0]:"), std::string::npos);
ASSERT_NE(stats.find("arenas[0]:"), std::string::npos) << stats;
}

} // anonymous namespace

TEST(je_ctl_test, dump_summary_stats)
{
std::string stats;
je_dump_stats(je_stats_type::SUMMARY_STATS, stats);
NO_FATALS(je_dump_stats(je_stats_type::SUMMARY_STATS, stats));

check_base_stats_marks_with_end(stats);
NO_FATALS(check_base_stats_marks_with_end(stats));
}

TEST(je_ctl_test, dump_configs)
{
std::string stats;
je_dump_stats(je_stats_type::CONFIGS, stats);
NO_FATALS(je_dump_stats(je_stats_type::CONFIGS, stats));

check_base_stats_marks_with_end(stats);
check_configs_marks(stats);
NO_FATALS(check_base_stats_marks_with_end(stats));
NO_FATALS(check_configs_marks(stats));
}

TEST(je_ctl_test, dump_brief_arena_stats)
{
std::string stats;
je_dump_stats(je_stats_type::BRIEF_ARENA_STATS, stats);
NO_FATALS(je_dump_stats(je_stats_type::BRIEF_ARENA_STATS, stats));

// Since there may be many arenas, "End" mark is not required to be checked here.
check_base_stats_marks(stats);
check_arena_marks(stats);
NO_FATALS(check_base_stats_marks(stats));
NO_FATALS(check_arena_marks(stats));
}

TEST(je_ctl_test, dump_detailed_stats)
{
std::string stats;
je_dump_stats(je_stats_type::DETAILED_STATS, stats);
NO_FATALS(je_dump_stats(je_stats_type::DETAILED_STATS, stats));

// Since there may be many arenas, "End" mark is not required to be checked here.
check_base_stats_marks(stats);
NO_FATALS(check_base_stats_marks(stats));

// Detailed stats will contain all information, therefore everything should be checked.
check_configs_marks(stats);
check_arena_marks(stats);
NO_FATALS(check_configs_marks(stats));
NO_FATALS(check_arena_marks(stats));
ASSERT_NE(stats.find("bins:"), std::string::npos);
ASSERT_NE(stats.find("extents:"), std::string::npos);
}
Expand Down

0 comments on commit 0ccf110

Please sign in to comment.