diff options
author | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-04-19 00:45:54 +0200 |
---|---|---|
committer | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-04-19 01:26:41 +0200 |
commit | faffcc561a8fc2c2ec6abbf94a0cf6578b945e32 (patch) | |
tree | 58d7ee2ea4b039cde76086a9f0300a2e77282fb6 /src/perfglue/heap_profiler.cc | |
parent | journaler: fix do_flush adjustment (diff) | |
download | ceph-faffcc561a8fc2c2ec6abbf94a0cf6578b945e32.tar.xz ceph-faffcc561a8fc2c2ec6abbf94a0cf6578b945e32.zip |
Change some global config options to env vars
Options that are inherently global, like malloc settings, and also
inherently debugging or profiling settings should be environment
variables.
tcmalloc_profiler_run, profiler_allocation_interval,
profiler_highwater_interval, and buffer_track_alloc fall into this
category.
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
Diffstat (limited to 'src/perfglue/heap_profiler.cc')
-rw-r--r-- | src/perfglue/heap_profiler.cc | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/src/perfglue/heap_profiler.cc b/src/perfglue/heap_profiler.cc index 71ab991e28c..0a73d9cb612 100644 --- a/src/perfglue/heap_profiler.cc +++ b/src/perfglue/heap_profiler.cc @@ -15,6 +15,7 @@ #include <google/heap-profiler.h> #include <google/malloc_extension.h> #include "heap_profiler.h" +#include "common/environment.h" #include "common/LogClient.h" bool ceph_using_tcmalloc() @@ -24,16 +25,10 @@ bool ceph_using_tcmalloc() void ceph_heap_profiler_init() { - char profile_name[PATH_MAX]; - sprintf(profile_name, "%s/%s", g_conf.log_dir.c_str(), g_conf.name.to_cstr()); - char *val = new char[sizeof(int)*8+1]; - sprintf(val, "%i", g_conf.profiler_allocation_interval); - setenv("HEAP_PROFILE_ALLOCATION_INTERVAL", val, g_conf.profiler_allocation_interval); - sprintf(val, "%i", g_conf.profiler_highwater_interval); - setenv("HEAP_PROFILE_INUSE_INTERVAL", val, g_conf.profiler_highwater_interval); - if (g_conf.tcmalloc_profiler_run) { - generic_dout(0) << "turning on heap profiler with prefix " << profile_name << dendl; - HeapProfilerStart(profile_name); + // Two other interesting environment variables to set are: + // HEAP_PROFILE_ALLOCATION_INTERVAL, HEAP_PROFILE_INUSE_INTERVAL + if (get_env_bool("CEPH_HEAP_PROFILER_INIT")) { + ceph_heap_profiler_start(); } } @@ -55,13 +50,10 @@ bool ceph_heap_profiler_running() void ceph_heap_profiler_start() { char profile_name[PATH_MAX]; - sprintf(profile_name, "%s/%s", g_conf.log_dir.c_str(), g_conf.name.to_cstr()); - char *val = new char[sizeof(int)*8+1]; - sprintf(val, "%i", g_conf.profiler_allocation_interval); - setenv("HEAP_PROFILE_ALLOCATION_INTERVAL", val, g_conf.profiler_allocation_interval); - sprintf(val, "%i", g_conf.profiler_highwater_interval); - setenv("HEAP_PROFILE_INUSE_INTERVAL", val, g_conf.profiler_highwater_interval); - generic_dout(0) << "turning on heap profiler with prefix " << profile_name << dendl; + snprintf(profile_name, sizeof(profile_name), + "%s/%s", g_conf.log_dir.c_str(), g_conf.name.to_cstr()); + generic_dout(0) << "turning on heap profiler with prefix " + << profile_name << dendl; HeapProfilerStart(profile_name); } @@ -88,14 +80,6 @@ void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd, << heap_stats << std::endl; ceph_heap_profiler_dump("admin request"); } - } else if (cmd.size() == 2 && cmd[1] == "export_config") { - char val[sizeof(int)*8+1]; - snprintf(val, sizeof(val), "%i", g_conf.profiler_allocation_interval); - setenv("HEAP_PROFILE_ALLOCATION_INTERVAL", val, g_conf.profiler_allocation_interval); - snprintf(val, sizeof(val), "%i", g_conf.profiler_highwater_interval); - setenv("HEAP_PROFILE_INUSE_INTERVAL", val, g_conf.profiler_highwater_interval); - clog.info() << g_conf.name << " set heap variables from " - << "current config"; } else if (cmd.size() == 2 && cmd[1] == "start_profiler") { ceph_heap_profiler_start(); clog.info() << g_conf.name << " started profiler \n"; |