Teaching cmake to always link in tcmalloc if it finds it.

Also renaming --enable-perftools to --enable-perftool-debug to
indicate that the switch is only relevant for debugging the heap. It's
not needed to pick up tcmalloc for better performance.

--with-perftools can still (and always) be used to give a hint where
to find the libraries.

With the threading, using tcmalloc improves memory usage on FreeBSD
significantly when running on a trace. If it fixes the live problems,
remains to be seen ...
This commit is contained in:
Robin Sommer 2012-03-28 14:53:59 -07:00
parent d7c9471818
commit 42066cc1fd
13 changed files with 40 additions and 31 deletions

View file

@ -89,11 +89,20 @@ if (LIBGEOIP_FOUND)
endif () endif ()
set(USE_PERFTOOLS false) set(USE_PERFTOOLS false)
if (ENABLE_PERFTOOLS) set(USE_PERFTOOLS_DEBUG false)
find_package(GooglePerftools)
if (GOOGLEPERFTOOLS_FOUND) find_package(GooglePerftools)
set(USE_PERFTOOLS true)
include_directories(BEFORE ${GooglePerftools_INCLUDE_DIR}) if (GOOGLEPERFTOOLS_FOUND)
include_directories(BEFORE ${GooglePerftools_INCLUDE_DIR})
set(USE_PERFTOOLS true)
if (ENABLE_PERFTOOLS_DEBUG)
# Enable heap debugging with perftools.
set(USE_PERFTOOLS_DEBUG true)
list(APPEND OPTLIBS ${GooglePerftools_LIBRARIES_DEBUG})
else ()
# Link in tcmalloc for better performance.
list(APPEND OPTLIBS ${GooglePerftools_LIBRARIES}) list(APPEND OPTLIBS ${GooglePerftools_LIBRARIES})
endif () endif ()
endif () endif ()
@ -183,6 +192,7 @@ message(
"\n" "\n"
"\nGeoIP: ${USE_GEOIP}" "\nGeoIP: ${USE_GEOIP}"
"\nGoogle perftools: ${USE_PERFTOOLS}" "\nGoogle perftools: ${USE_PERFTOOLS}"
"\n debugging: ${USE_PERFTOOLS_DEBUG}"
"\n" "\n"
"\n================================================================\n" "\n================================================================\n"
) )

2
cmake

@ -1 +1 @@
Subproject commit 2cc105577044a2d214124568f3f2496ed2ccbb34 Subproject commit 4b573ed849f131ebb8e34fa24786d56f9805e444

9
configure vendored
View file

@ -27,7 +27,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
Optional Features: Optional Features:
--enable-debug compile in debugging mode --enable-debug compile in debugging mode
--enable-perftools use Google's perftools --enable-perftools-debug use Google's perftools for debugging
--disable-broccoli don't build or install the Broccoli library --disable-broccoli don't build or install the Broccoli library
--disable-broctl don't install Broctl --disable-broctl don't install Broctl
--disable-auxtools don't build or install auxilliary tools --disable-auxtools don't build or install auxilliary tools
@ -91,7 +91,7 @@ append_cache_entry BRO_ROOT_DIR PATH /usr/local/bro
append_cache_entry PY_MOD_INSTALL_DIR PATH /usr/local/bro/lib/broctl append_cache_entry PY_MOD_INSTALL_DIR PATH /usr/local/bro/lib/broctl
append_cache_entry BRO_SCRIPT_INSTALL_PATH STRING /usr/local/bro/share/bro append_cache_entry BRO_SCRIPT_INSTALL_PATH STRING /usr/local/bro/share/bro
append_cache_entry ENABLE_DEBUG BOOL false append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry ENABLE_PERFTOOLS BOOL false append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL false
append_cache_entry BinPAC_SKIP_INSTALL BOOL true append_cache_entry BinPAC_SKIP_INSTALL BOOL true
append_cache_entry BUILD_SHARED_LIBS BOOL true append_cache_entry BUILD_SHARED_LIBS BOOL true
append_cache_entry INSTALL_AUX_TOOLS BOOL true append_cache_entry INSTALL_AUX_TOOLS BOOL true
@ -132,8 +132,8 @@ while [ $# -ne 0 ]; do
--enable-debug) --enable-debug)
append_cache_entry ENABLE_DEBUG BOOL true append_cache_entry ENABLE_DEBUG BOOL true
;; ;;
--enable-perftools) --enable-perftools-debug)
append_cache_entry ENABLE_PERFTOOLS BOOL true append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
;; ;;
--disable-broccoli) --disable-broccoli)
append_cache_entry INSTALL_BROCCOLI BOOL false append_cache_entry INSTALL_BROCCOLI BOOL false
@ -178,7 +178,6 @@ while [ $# -ne 0 ]; do
append_cache_entry LibGeoIP_ROOT_DIR PATH $optarg append_cache_entry LibGeoIP_ROOT_DIR PATH $optarg
;; ;;
--with-perftools=*) --with-perftools=*)
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg
;; ;;
--with-python=*) --with-python=*)

View file

@ -74,7 +74,7 @@ void DPM::PostScriptInit()
void DPM::AddConfig(const Analyzer::Config& cfg) void DPM::AddConfig(const Analyzer::Config& cfg)
{ {
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
#endif #endif

View file

@ -232,7 +232,7 @@ BroFile::~BroFile()
delete [] access; delete [] access;
delete [] cipher_buffer; delete [] cipher_buffer;
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
heap_checker->UnIgnoreObject(this); heap_checker->UnIgnoreObject(this);
#endif #endif
} }
@ -255,7 +255,7 @@ void BroFile::Init()
cipher_ctx = 0; cipher_ctx = 0;
cipher_buffer = 0; cipher_buffer = 0;
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
heap_checker->IgnoreObject(this); heap_checker->IgnoreObject(this);
#endif #endif
} }

View file

@ -372,7 +372,7 @@ ID* ID::Unserialize(UnserialInfo* info)
Ref(id); Ref(id);
global_scope()->Insert(id->Name(), id); global_scope()->Insert(id->Name(), id);
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
heap_checker->IgnoreObject(id); heap_checker->IgnoreObject(id);
#endif #endif
} }

View file

@ -38,7 +38,7 @@ Login_Analyzer::Login_Analyzer(AnalyzerTag::Tag tag, Connection* conn)
if ( ! re_skip_authentication ) if ( ! re_skip_authentication )
{ {
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
#endif #endif
re_skip_authentication = init_RE(skip_authentication); re_skip_authentication = init_RE(skip_authentication);

View file

@ -137,7 +137,7 @@ bool PersistenceSerializer::CheckForFile(UnserialInfo* info, const char* file,
bool PersistenceSerializer::ReadAll(bool is_init, bool delete_files) bool PersistenceSerializer::ReadAll(bool is_init, bool delete_files)
{ {
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
#endif #endif

View file

@ -2645,7 +2645,7 @@ bool RemoteSerializer::ProcessLogCreateWriter()
if ( current_peer->state == Peer::CLOSING ) if ( current_peer->state == Peer::CLOSING )
return false; return false;
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
// Don't track allocations here, they'll be released only after the // Don't track allocations here, they'll be released only after the
// main loop exists. And it's just a tiny amount anyway. // main loop exists. And it's just a tiny amount anyway.
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
@ -2866,7 +2866,7 @@ void RemoteSerializer::GotID(ID* id, Val* val)
(desc && *desc) ? desc : "not set"), (desc && *desc) ? desc : "not set"),
current_peer); current_peer);
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
// May still be cached, but we don't care. // May still be cached, but we don't care.
heap_checker->IgnoreObject(id); heap_checker->IgnoreObject(id);
#endif #endif

View file

@ -191,7 +191,7 @@ void RuleMatcher::Delete(RuleHdrTest* node)
bool RuleMatcher::ReadFiles(const name_list& files) bool RuleMatcher::ReadFiles(const name_list& files)
{ {
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
#endif #endif

View file

@ -678,7 +678,7 @@ bool StateAccess::DoUnserialize(UnserialInfo* info)
target.id = new ID(name, SCOPE_GLOBAL, true); target.id = new ID(name, SCOPE_GLOBAL, true);
Ref(target.id); Ref(target.id);
global_scope()->Insert(name, target.id); global_scope()->Insert(name, target.id);
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
heap_checker->IgnoreObject(target.id); heap_checker->IgnoreObject(target.id);
#endif #endif
} }

View file

@ -65,7 +65,7 @@ extern "C" {
#include "setsignal.h" #include "setsignal.h"
}; };
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
HeapLeakChecker* heap_checker = 0; HeapLeakChecker* heap_checker = 0;
int perftools_leaks = 0; int perftools_leaks = 0;
int perftools_profile = 0; int perftools_profile = 0;
@ -177,7 +177,7 @@ void usage()
fprintf(stderr, " -W|--watchdog | activate watchdog timer\n"); fprintf(stderr, " -W|--watchdog | activate watchdog timer\n");
fprintf(stderr, " -Z|--doc-scripts | generate documentation for all loaded scripts\n"); fprintf(stderr, " -Z|--doc-scripts | generate documentation for all loaded scripts\n");
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
fprintf(stderr, " -m|--mem-leaks | show leaks [perftools]\n"); fprintf(stderr, " -m|--mem-leaks | show leaks [perftools]\n");
fprintf(stderr, " -M|--mem-profile | record heap [perftools]\n"); fprintf(stderr, " -M|--mem-profile | record heap [perftools]\n");
#endif #endif
@ -244,7 +244,7 @@ void done_with_network()
net_finish(1); net_finish(1);
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
if ( perftools_profile ) if ( perftools_profile )
{ {
@ -424,7 +424,7 @@ int main(int argc, char** argv)
#ifdef USE_IDMEF #ifdef USE_IDMEF
{"idmef-dtd", required_argument, 0, 'n'}, {"idmef-dtd", required_argument, 0, 'n'},
#endif #endif
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
{"mem-leaks", no_argument, 0, 'm'}, {"mem-leaks", no_argument, 0, 'm'},
{"mem-profile", no_argument, 0, 'M'}, {"mem-profile", no_argument, 0, 'M'},
#endif #endif
@ -466,7 +466,7 @@ int main(int argc, char** argv)
safe_strncpy(opts, "B:D:e:f:I:i:K:l:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLOPSWbdghvZ", safe_strncpy(opts, "B:D:e:f:I:i:K:l:n:p:R:r:s:T:t:U:w:x:X:y:Y:z:CFGLOPSWbdghvZ",
sizeof(opts)); sizeof(opts));
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
strncat(opts, "mM", 2); strncat(opts, "mM", 2);
#endif #endif
@ -622,7 +622,7 @@ int main(int argc, char** argv)
exit(0); exit(0);
break; break;
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
case 'm': case 'm':
perftools_leaks = 1; perftools_leaks = 1;
break; break;
@ -758,14 +758,14 @@ int main(int argc, char** argv)
// nevertheless reported; see perftools docs), thus // nevertheless reported; see perftools docs), thus
// we suppress some messages here. // we suppress some messages here.
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
{ {
HeapLeakChecker::Disabler disabler; HeapLeakChecker::Disabler disabler;
#endif #endif
yyparse(); yyparse();
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
} }
#endif #endif
@ -1019,7 +1019,7 @@ int main(int argc, char** argv)
if ( profiling_logger ) if ( profiling_logger )
profiling_logger->Log(); profiling_logger->Log();
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
if ( perftools_leaks ) if ( perftools_leaks )
heap_checker = new HeapLeakChecker("net_run"); heap_checker = new HeapLeakChecker("net_run");

View file

@ -37,7 +37,7 @@
#endif #endif
#ifdef USE_PERFTOOLS #ifdef USE_PERFTOOLS_DEBUG
#include <google/heap-checker.h> #include <google/heap-checker.h>
#include <google/heap-profiler.h> #include <google/heap-profiler.h>
extern HeapLeakChecker* heap_checker; extern HeapLeakChecker* heap_checker;