Add sample interval to prof last-N dump
This commit is contained in:
parent
cf2549a149
commit
9545c2cd36
@ -540,6 +540,9 @@ prof_recent_alloc_dump(tsd_t *tsd, write_cb_t *write_cb, void *cbopaque) {
|
|||||||
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_recent_alloc_mtx);
|
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_recent_alloc_mtx);
|
||||||
|
|
||||||
emitter_begin(&emitter);
|
emitter_begin(&emitter);
|
||||||
|
uint64_t sample_interval = (uint64_t)1U << lg_prof_sample;
|
||||||
|
emitter_json_kv(&emitter, "sample_interval", emitter_type_uint64,
|
||||||
|
&sample_interval);
|
||||||
emitter_json_kv(&emitter, "recent_alloc_max", emitter_type_ssize,
|
emitter_json_kv(&emitter, "recent_alloc_max", emitter_type_ssize,
|
||||||
&dump_max);
|
&dump_max);
|
||||||
emitter_json_array_kv_begin(&emitter, "recent_alloc");
|
emitter_json_array_kv_begin(&emitter, "recent_alloc");
|
||||||
|
@ -370,16 +370,16 @@ typedef struct {
|
|||||||
#define DUMP_ERROR "Dump output is wrong"
|
#define DUMP_ERROR "Dump output is wrong"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
confirm_record(const char *template,
|
confirm_record(const char *template, const confirm_record_t *records,
|
||||||
const confirm_record_t *records, const size_t n_records) {
|
const size_t n_records) {
|
||||||
static const char *types[2] = {"alloc", "dalloc"};
|
static const char *types[2] = {"alloc", "dalloc"};
|
||||||
static char buf[64];
|
static char buf[64];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The template string would be in the form of:
|
* The template string would be in the form of:
|
||||||
* "{\"recent_alloc_max\":XYZ,\"recent_alloc\":[]}",
|
* "{...,\"recent_alloc\":[]}",
|
||||||
* and dump_out would be in the form of:
|
* and dump_out would be in the form of:
|
||||||
* "{\"recent_alloc_max\":XYZ,\"recent_alloc\":[...]}".
|
* "{...,\"recent_alloc\":[...]}".
|
||||||
* Using "- 2" serves to cut right before the ending "]}".
|
* Using "- 2" serves to cut right before the ending "]}".
|
||||||
*/
|
*/
|
||||||
assert_d_eq(memcmp(dump_out, template, strlen(template) - 2), 0,
|
assert_d_eq(memcmp(dump_out, template, strlen(template) - 2), 0,
|
||||||
@ -489,18 +489,22 @@ TEST_BEGIN(test_prof_recent_alloc_dump) {
|
|||||||
void *p, *q;
|
void *p, *q;
|
||||||
confirm_record_t records[2];
|
confirm_record_t records[2];
|
||||||
|
|
||||||
|
assert_zu_eq(lg_prof_sample, (size_t)0,
|
||||||
|
"lg_prof_sample not set correctly");
|
||||||
|
|
||||||
future = 0;
|
future = 0;
|
||||||
assert_d_eq(mallctl("experimental.prof_recent.alloc_max",
|
assert_d_eq(mallctl("experimental.prof_recent.alloc_max",
|
||||||
NULL, NULL, &future, sizeof(ssize_t)), 0, "Write error");
|
NULL, NULL, &future, sizeof(ssize_t)), 0, "Write error");
|
||||||
call_dump();
|
call_dump();
|
||||||
expect_str_eq(dump_out, "{\"recent_alloc_max\":0,\"recent_alloc\":[]}",
|
expect_str_eq(dump_out, "{\"sample_interval\":1,"
|
||||||
DUMP_ERROR);
|
"\"recent_alloc_max\":0,\"recent_alloc\":[]}", DUMP_ERROR);
|
||||||
|
|
||||||
future = 2;
|
future = 2;
|
||||||
assert_d_eq(mallctl("experimental.prof_recent.alloc_max",
|
assert_d_eq(mallctl("experimental.prof_recent.alloc_max",
|
||||||
NULL, NULL, &future, sizeof(ssize_t)), 0, "Write error");
|
NULL, NULL, &future, sizeof(ssize_t)), 0, "Write error");
|
||||||
call_dump();
|
call_dump();
|
||||||
const char *template = "{\"recent_alloc_max\":2,\"recent_alloc\":[]}";
|
const char *template = "{\"sample_interval\":1,"
|
||||||
|
"\"recent_alloc_max\":2,\"recent_alloc\":[]}";
|
||||||
expect_str_eq(dump_out, template, DUMP_ERROR);
|
expect_str_eq(dump_out, template, DUMP_ERROR);
|
||||||
|
|
||||||
p = malloc(7);
|
p = malloc(7);
|
||||||
|
Loading…
Reference in New Issue
Block a user