Clarify relationship between stats.resident and stats.mapped.

This commit is contained in:
Jason Evans 2015-05-28 15:03:58 -07:00
parent 09983d2f54
commit 56048baeb4
3 changed files with 15 additions and 7 deletions

View File

@ -1964,10 +1964,12 @@ malloc_conf = "xmalloc:true";]]></programlisting>
[<option>--enable-stats</option>] [<option>--enable-stats</option>]
</term> </term>
<listitem><para>Total number of bytes in active chunks mapped by the <listitem><para>Total number of bytes in active chunks mapped by the
allocator. This is a multiple of the chunk size, and is at least as allocator. This is a multiple of the chunk size, and is larger than
large as <link <link linkend="stats.active"><mallctl>stats.active</mallctl></link>.
linkend="stats.resident"><mallctl>stats.resident</mallctl></link>. This This does not include inactive chunks, even those that contain unused
does not include inactive chunks.</para></listitem> dirty pages, which means that there is no strict ordering between this
and <link
linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="stats.arenas.i.dss"> <varlistentry id="stats.arenas.i.dss">

View File

@ -132,6 +132,8 @@ base_stats_get(size_t *allocated, size_t *resident, size_t *mapped)
{ {
malloc_mutex_lock(&base_mtx); malloc_mutex_lock(&base_mtx);
assert(base_allocated <= base_resident);
assert(base_resident <= base_mapped);
*allocated = base_allocated; *allocated = base_allocated;
*resident = base_resident; *resident = base_resident;
*mapped = base_mapped; *mapped = base_mapped;

View File

@ -3,7 +3,7 @@
TEST_BEGIN(test_stats_summary) TEST_BEGIN(test_stats_summary)
{ {
size_t *cactive; size_t *cactive;
size_t sz, allocated, active, mapped; size_t sz, allocated, active, resident, mapped;
int expected = config_stats ? 0 : ENOENT; int expected = config_stats ? 0 : ENOENT;
sz = sizeof(cactive); sz = sizeof(cactive);
@ -15,6 +15,8 @@ TEST_BEGIN(test_stats_summary)
expected, "Unexpected mallctl() result"); expected, "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.active", &active, &sz, NULL, 0), expected, assert_d_eq(mallctl("stats.active", &active, &sz, NULL, 0), expected,
"Unexpected mallctl() result"); "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.resident", &resident, &sz, NULL, 0),
expected, "Unexpected mallctl() result");
assert_d_eq(mallctl("stats.mapped", &mapped, &sz, NULL, 0), expected, assert_d_eq(mallctl("stats.mapped", &mapped, &sz, NULL, 0), expected,
"Unexpected mallctl() result"); "Unexpected mallctl() result");
@ -23,8 +25,10 @@ TEST_BEGIN(test_stats_summary)
"active should be no larger than cactive"); "active should be no larger than cactive");
assert_zu_le(allocated, active, assert_zu_le(allocated, active,
"allocated should be no larger than active"); "allocated should be no larger than active");
assert_zu_le(active, mapped, assert_zu_lt(active, resident,
"active should be no larger than mapped"); "active should be less than resident");
assert_zu_lt(active, mapped,
"active should be less than mapped");
} }
} }
TEST_END TEST_END