metadata usage breakdowns: tracking edata and rtree usages

This commit is contained in:
Shirui Cheng
2023-10-10 09:46:23 -07:00
committed by Qi Wang
parent 005f20aa7f
commit 36becb1302
10 changed files with 116 additions and 30 deletions

View File

@@ -28,7 +28,8 @@ static extent_hooks_t hooks_not_null = {
TEST_BEGIN(test_base_hooks_default) {
base_t *base;
size_t allocated0, allocated1, resident, mapped, n_thp;
size_t allocated0, allocated1, edata_allocated,
rtree_allocated, resident, mapped, n_thp;
tsdn_t *tsdn = tsd_tsdn(tsd_fetch());
base = base_new(tsdn, 0,
@@ -36,8 +37,8 @@ TEST_BEGIN(test_base_hooks_default) {
/* metadata_use_hooks */ true);
if (config_stats) {
base_stats_get(tsdn, base, &allocated0, &resident, &mapped,
&n_thp);
base_stats_get(tsdn, base, &allocated0, &edata_allocated,
&rtree_allocated, &resident, &mapped, &n_thp);
expect_zu_ge(allocated0, sizeof(base_t),
"Base header should count as allocated");
if (opt_metadata_thp == metadata_thp_always) {
@@ -50,8 +51,8 @@ TEST_BEGIN(test_base_hooks_default) {
"Unexpected base_alloc() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated1, &resident, &mapped,
&n_thp);
base_stats_get(tsdn, base, &allocated1, &edata_allocated,
&rtree_allocated, &resident, &mapped, &n_thp);
expect_zu_ge(allocated1 - allocated0, 42,
"At least 42 bytes were allocated by base_alloc()");
}
@@ -63,7 +64,8 @@ TEST_END
TEST_BEGIN(test_base_hooks_null) {
extent_hooks_t hooks_orig;
base_t *base;
size_t allocated0, allocated1, resident, mapped, n_thp;
size_t allocated0, allocated1, edata_allocated,
rtree_allocated, resident, mapped, n_thp;
extent_hooks_prep();
try_dalloc = false;
@@ -79,8 +81,8 @@ TEST_BEGIN(test_base_hooks_null) {
expect_ptr_not_null(base, "Unexpected base_new() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated0, &resident, &mapped,
&n_thp);
base_stats_get(tsdn, base, &allocated0, &edata_allocated,
&rtree_allocated, &resident, &mapped, &n_thp);
expect_zu_ge(allocated0, sizeof(base_t),
"Base header should count as allocated");
if (opt_metadata_thp == metadata_thp_always) {
@@ -93,8 +95,8 @@ TEST_BEGIN(test_base_hooks_null) {
"Unexpected base_alloc() failure");
if (config_stats) {
base_stats_get(tsdn, base, &allocated1, &resident, &mapped,
&n_thp);
base_stats_get(tsdn, base, &allocated1, &edata_allocated,
&rtree_allocated, &resident, &mapped, &n_thp);
expect_zu_ge(allocated1 - allocated0, 42,
"At least 42 bytes were allocated by base_alloc()");
}

View File

@@ -4,7 +4,8 @@
#define STRINGIFY(x) STRINGIFY_HELPER(x)
TEST_BEGIN(test_stats_summary) {
size_t sz, allocated, active, resident, mapped;
size_t sz, allocated, active, resident, mapped,
metadata, metadata_edata, metadata_rtree;
int expected = config_stats ? 0 : ENOENT;
sz = sizeof(size_t);
@@ -17,6 +18,13 @@ TEST_BEGIN(test_stats_summary) {
expect_d_eq(mallctl("stats.mapped", (void *)&mapped, &sz, NULL, 0),
expected, "Unexpected mallctl() result");
expect_d_eq(mallctl("stats.metadata", (void *)&metadata, &sz, NULL, 0),
expected, "Unexpected mallctl() result");
expect_d_eq(mallctl("stats.metadata_edata", (void *)&metadata_edata,
&sz, NULL, 0), expected, "Unexpected mallctl() result");
expect_d_eq(mallctl("stats.metadata_rtree", (void *)&metadata_rtree,
&sz, NULL, 0), expected, "Unexpected mallctl() result");
if (config_stats) {
expect_zu_le(allocated, active,
"allocated should be no larger than active");
@@ -24,6 +32,9 @@ TEST_BEGIN(test_stats_summary) {
"active should be less than resident");
expect_zu_lt(active, mapped,
"active should be less than mapped");
expect_zu_le(metadata_edata + metadata_rtree, metadata,
"the sum of metadata_edata and metadata_rtree "
"should be no larger than metadata");
}
}
TEST_END