Print jemalloc default config on startup

Since jemalloc config can be changed via 'MALLOC_CONF' env variable,
printing on startup ensures that we can check in the error log if the
default config has been overridden.
pull/4506/head
Javier Jaramago Fernández 2 years ago
parent 288eee1405
commit 0a38bd435d

@ -149,11 +149,18 @@ ifeq ($(TEST_WITHASAN),1)
WASAN += -DTEST_WITHASAN
endif
NOJEMALLOC := $(shell echo $(NOJEMALLOC))
ifeq ($(NOJEMALLOC),1)
NOJEM=-DNOJEM
else
NOJEM=
endif
MYCXXFLAGS := $(STDCPP)
ifeq ($(CXX),clang++)
MYCXXFLAGS += -fuse-ld=lld
endif
MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(WGCOV) $(WASAN)
MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN)
STATICMYLIBS := -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lssl -lcrypto -lev

@ -1902,7 +1902,61 @@ void handleProcessRestart() {
} while (pid > 0);
}
#ifndef NOJEM
int print_jemalloc_conf() {
int rc = 0;
bool xmalloc = 0;
bool prof_accum = 0;
bool prof_leak = 0;
size_t lg_cache_max = 0;
size_t lg_prof_sample = 0;
size_t lg_prof_interval = 0;
size_t bool_sz = sizeof(bool);
size_t size_sz = sizeof(size_t);
size_t ssize_sz = sizeof(ssize_t);
rc = mallctl("config.xmalloc", &xmalloc, &bool_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'config.xmalloc' with error %d", rc); return rc; }
rc = mallctl("opt.lg_tcache_max", &lg_cache_max, &size_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'opt.lg_tcache_max' with error %d", rc); return rc; }
rc = mallctl("opt.prof_accum", &prof_accum, &bool_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'opt.prof_accum' with error %d", rc); return rc; }
rc = mallctl("opt.prof_leak", &prof_leak, &bool_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'opt.prof_leak' with error %d", rc); return rc; }
rc = mallctl("opt.lg_prof_sample", &lg_prof_sample, &size_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'opt.lg_prof_sample' with error %d", rc); return rc; }
rc = mallctl("opt.lg_prof_interval", &lg_prof_interval, &ssize_sz, NULL, 0);
if (rc) { proxy_error("Failed to fetch 'opt.lg_prof_interval' with error %d", rc); return rc; }
proxy_info(
"Using jemalloc with MALLOC_CONF:"
" config.xmalloc:%d, lg_tcache_max:%lu, opt.prof_accum:%d, opt.prof_leak:%d,"
" opt.lg_prof_sample:%lu, opt.lg_prof_interval:%lu, rc:%d\n",
xmalloc, lg_cache_max, prof_accum, prof_leak, lg_prof_sample, lg_prof_interval, rc
);
return 0;
}
#else
int print_jemalloc_conf() {
return 0;
}
#endif
int main(int argc, const char * argv[]) {
// Output current jemalloc conf; no action taken when disabled
{
int rc = print_jemalloc_conf();
if (rc) { exit(EXIT_FAILURE); }
}
{
MYSQL *my = mysql_init(NULL);

Loading…
Cancel
Save