diff options
author | Jason Evans <je@facebook.com> | 2010-04-01 01:43:24 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-04-01 01:43:24 (GMT) |
commit | f18c98200145de70779a1b3286e7829b0268231e (patch) | |
tree | 95fa6b8e63861d0d34efd0ca4bc5008fe9cc6512 /jemalloc/src | |
parent | a02fc08ec9dd8479a6430155b6a433da09f6ff10 (diff) | |
download | jemalloc-f18c98200145de70779a1b3286e7829b0268231e.zip jemalloc-f18c98200145de70779a1b3286e7829b0268231e.tar.gz jemalloc-f18c98200145de70779a1b3286e7829b0268231e.tar.bz2 |
Add sampling activation/deactivation control.
Add the E/e options to control whether the application starts with
sampling active/inactive (secondary control to F/f). Add the
prof.active mallctl so that the application can activate/deactivate
sampling on the fly.
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/ctl.c | 29 | ||||
-rw-r--r-- | jemalloc/src/jemalloc.c | 6 | ||||
-rw-r--r-- | jemalloc/src/prof.c | 6 |
3 files changed, 40 insertions, 1 deletions
diff --git a/jemalloc/src/ctl.c b/jemalloc/src/ctl.c index f628c13..ffb732d 100644 --- a/jemalloc/src/ctl.c +++ b/jemalloc/src/ctl.c @@ -75,6 +75,7 @@ CTL_PROTO(opt_lg_tcache_gc_sweep) #endif #ifdef JEMALLOC_PROF CTL_PROTO(opt_prof) +CTL_PROTO(opt_prof_active) CTL_PROTO(opt_lg_prof_bt_max) CTL_PROTO(opt_lg_prof_sample) CTL_PROTO(opt_lg_prof_interval) @@ -125,6 +126,7 @@ CTL_PROTO(arenas_nhbins) #endif CTL_PROTO(arenas_nlruns) #ifdef JEMALLOC_PROF +CTL_PROTO(prof_active) CTL_PROTO(prof_dump) CTL_PROTO(prof_interval) #endif @@ -246,6 +248,7 @@ static const ctl_node_t opt_node[] = { #endif #ifdef JEMALLOC_PROF {NAME("prof"), CTL(opt_prof)}, + {NAME("prof_active"), CTL(opt_prof_active)}, {NAME("lg_prof_bt_max"), CTL(opt_lg_prof_bt_max)}, {NAME("lg_prof_sample"), CTL(opt_lg_prof_sample)}, {NAME("lg_prof_interval"), CTL(opt_lg_prof_interval)}, @@ -323,6 +326,7 @@ static const ctl_node_t arenas_node[] = { #ifdef JEMALLOC_PROF static const ctl_node_t prof_node[] = { + {NAME("active"), CTL(prof_active)}, {NAME("dump"), CTL(prof_dump)}, {NAME("interval"), CTL(prof_interval)} }; @@ -1151,6 +1155,7 @@ CTL_RO_GEN(opt_lg_tcache_gc_sweep, opt_lg_tcache_gc_sweep, ssize_t) #endif #ifdef JEMALLOC_PROF CTL_RO_GEN(opt_prof, opt_prof, bool) +CTL_RO_GEN(opt_prof_active, opt_prof_active, bool) CTL_RO_GEN(opt_lg_prof_bt_max, opt_lg_prof_bt_max, size_t) CTL_RO_GEN(opt_lg_prof_sample, opt_lg_prof_sample, size_t) CTL_RO_GEN(opt_lg_prof_interval, opt_lg_prof_interval, ssize_t) @@ -1248,6 +1253,30 @@ CTL_RO_GEN(arenas_nlruns, nlclasses, size_t) #ifdef JEMALLOC_PROF static int +prof_active_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) +{ + int ret; + bool oldval; + + oldval = opt_prof_active; + if (newp != NULL) { + /* + * The memory barriers will tend to make opt_prof_active + * propagate faster on systems with weak memory ordering. + */ + mb_write(); + WRITE(opt_prof_active, bool); + mb_write(); + } + READ(oldval, bool); + + ret = 0; +RETURN: + return (ret); +} + +static int prof_dump_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index d3c7cca..e01de0d 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -460,6 +460,12 @@ MALLOC_OUT: opt_lg_dirty_mult--; break; #ifdef JEMALLOC_PROF + case 'e': + opt_prof_active = false; + break; + case 'E': + opt_prof_active = true; + break; case 'f': opt_prof = false; break; diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index 97db422..4cdebb9 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -18,6 +18,7 @@ /* Data. */ bool opt_prof = false; +bool opt_prof_active = true; size_t opt_lg_prof_bt_max = LG_PROF_BT_MAX_DEFAULT; size_t opt_lg_prof_sample = LG_PROF_SAMPLE_DEFAULT; ssize_t opt_lg_prof_interval = LG_PROF_INTERVAL_DEFAULT; @@ -537,7 +538,10 @@ prof_alloc_prep(size_t size) void *vec[prof_bt_max]; prof_bt_t bt; - if (opt_lg_prof_sample == 0) { + if (opt_prof_active == false) { + /* Sampling is currently inactive, so avoid sampling. */ + ret = (prof_thr_cnt_t *)(uintptr_t)1U; + } else if (opt_lg_prof_sample == 0) { /* * Don't bother with sampling logic, since sampling interval is * 1. |