parse_startup_config_options(args, module_type);
parse_config_options(args);
+#ifdef HAVE_LIBTCMALLOC
+ if (g_conf.tcmalloc_profiler_run && g_conf.tcmalloc_have) {
+ char *profile_name = new char[PATH_MAX];
+ sprintf(profile_name, "%s/%s", g_conf.log_dir, g_conf.name);
+ 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", "", g_conf.profiler_highwater_interval);
+ generic_dout(0) << "turning on heap profiler with prefix " << profile_name << dendl;
+ g_conf.profiler_start(profile_name);
+ delete profile_name;
+ }
+#endif //HAVE_LIBTCMALLOC
+
if (g_conf.log_file && g_conf.log_file[0])
g_conf.log_to_stdout = false;
OPTION(monmap, 'M', OPT_STR, 0),
OPTION(mon_host, 'm', OPT_STR, 0),
OPTION(daemonize, 'd', OPT_BOOL, false),
+ OPTION(tcmalloc_profiler_run, 0, OPT_BOOL, false),
+ OPTION(profiler_allocation_interval, 0, OPT_INT, 1073741824),
+ OPTION(profiler_highwater_interval, 0, OPT_INT, 104857600),
OPTION(logger, 0, OPT_BOOL, false),
OPTION(logger_interval, 0, OPT_INT, 1),
OPTION(logger_calc_variance, 0, OPT_BOOL, true),
}
}
}
-
// open new conf
string fn = g_conf.conf;
list<string> ls;
#include "msg/msg_types.h"
+#ifdef HAVE_LIBTCMALLOC
+#include <google/heap-profiler.h>
+#endif //HAVE_LIBTCMALLOC
+
extern bool g_daemon;
extern const char *g_default_id;
const char *mon_host;
bool daemonize;
+ //profiling
+ bool tcmalloc_have;
+ bool tcmalloc_profiler_run;
+ void (*profiler_start)(const char*);
+ bool (*profiler_running)();
+ void (*profiler_stop)();
+ void (*profiler_dump)(const char*);
+ int profiler_allocation_interval;
+ int profiler_highwater_interval;
+
// logger (profiling)
bool logger;
int logger_interval;