From 6e0bebdacf89b4fc8b401f417bc8f3570a79f55d Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 7 Mar 2014 15:40:55 +0800 Subject: [PATCH] full support gperf gmc/gmp/gcp --- trunk/auto/options.sh | 12 ++++++++++++ trunk/configure | 12 +++++++++--- trunk/src/app/srs_app_server.cpp | 7 +++++-- trunk/src/main/srs_main_server.cpp | 22 ++++++++++++++++------ 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index d456b6e5d..fdec39b4c 100644 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -115,6 +115,8 @@ if [ $help = yes ]; then --with-utest build the utest for srs. --with-gperf build srs with gperf tools(no gmc/gmp/gcp, with tcmalloc only). --with-gmc build memory check for srs with gperf tools. + --with-gmp build memory profile for srs with gperf tools. + --with-gcp build cpu profile for srs with gperf tools. --without-ssl disable rtmp complex handshake. --without-hls disable hls, rtmp streaming only. @@ -124,6 +126,8 @@ if [ $help = yes ]; then --without-utest do not build the utest for srs. --without-gperf do not build srs with gperf tools(without tcmalloc and gmc/gmp/gcp). --without-gmc do not build memory check for srs with gperf tools. + --without-gmp do not build memory profile for srs with gperf tools. + --without-gcp do not build cpu profile for srs with gperf tools. --jobs[=N] Allow N jobs at once; infinite jobs with no arg. used for make in the configure, for example, to make ffmpeg. @@ -151,6 +155,14 @@ if [ $SRS_GPERF = NO ]; then __check_ok=NO fi fi +if [ $SRS_GPERF_MC = YES ]; then + if [ $SRS_GPERF_MP = YES ]; then + echo "gperf-mc not compatible with gperf-mp, see: ./configure --help"; + echo "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html"; + echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time"; + __check_ok=NO + fi +fi # check variable neccessary if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; diff --git a/trunk/configure b/trunk/configure index 2a363fa61..cc08d2eb0 100755 --- a/trunk/configure +++ b/trunk/configure @@ -67,6 +67,7 @@ SrsUtestSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_UTEST = YES ]; then SrsU SrsGperfSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\$(GREEN)"; fi SrsGperfMCSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\$(GREEN)"; fi SrsGperfMPSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\$(GREEN)"; fi +SrsGperfCPSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\$(GREEN)"; fi ##################################################################################### # makefile @@ -98,9 +99,14 @@ default: bandwidth librtmp-sample utest @echo -e " ${SrsGperfMCSummaryColor}gmc: gperf memory check, @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\$(BLACK)" @echo -e " ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/srs.conf # start gmc\$(BLACK)" @echo -e " ${SrsGperfMCSummaryColor}killall -2 srs # or CTRL+C to stop gmc\$(BLACK)" - @echo -e " ${SrsGperfMPSummaryColor}gmc: gperf memory profile, @see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html\$(BLACK)" - @echo -e " ${SrsGperfMPSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/srs.conf # start gmc\$(BLACK)" - @echo -e " ${SrsGperfMPSummaryColor}killall -2 srs # or CTRL+C to stop gmc\$(BLACK)" + @echo -e " ${SrsGperfMPSummaryColor}gmp: gperf memory profile, @see: http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html\$(BLACK)" + @echo -e " ${SrsGperfMPSummaryColor}rm -f gperf.srs.gmp*; ./objs/srs -c conf/srs.conf # start gmp\$(BLACK)" + @echo -e " ${SrsGperfMPSummaryColor}killall -2 srs # or CTRL+C to stop gmp\$(BLACK)" + @echo -e " ${SrsGperfMPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gmp* # to analysis memory profile\$(BLACK)" + @echo -e " ${SrsGperfCPSummaryColor}gcp: gperf cpu profile, @see: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html\$(BLACK)" + @echo -e " ${SrsGperfCPSummaryColor}rm -f gperf.srs.gcp*; ./objs/srs -c conf/srs.conf # start gcp\$(BLACK)" + @echo -e " ${SrsGperfCPSummaryColor}killall -2 srs # or CTRL+C to stop gcp\$(BLACK)" + @echo -e " ${SrsGperfCPSummaryColor}./objs/pprof --text objs/srs gperf.srs.gcp* # to analysis cpu profile\$(BLACK)" @echo -e "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)" help: diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index e1ef9a970..b10f364eb 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -281,13 +281,16 @@ void SrsServer::on_signal(int signo) return; } -#ifdef SRS_GPERF_MC if (signo == SIGINT) { +#ifdef SRS_GPERF_MC srs_trace("gmc is on, main cycle will terminate normally."); signal_gmc_stop = true; +#else + srs_trace("user terminate program"); + exit(0); +#endif return; } -#endif // TODO: handle the SIGINT, SIGTERM. } diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 8f3b34292..53d6c7c05 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -37,10 +37,10 @@ SrsServer* _srs_server = new SrsServer(); #include #include -#ifdef SRS_GPERF_HEAP_PROFILE +#ifdef SRS_GPERF_MP #include #endif -#ifdef SRS_GPERF_CPU_PROFILE +#ifdef SRS_GPERF_CP #include #endif @@ -54,11 +54,11 @@ int main(int argc, char** argv) { int ret = ERROR_SUCCESS; -#ifdef SRS_GPERF_HEAP_PROFILE - HeapProfilerStart("gperf.srs"); +#ifdef SRS_GPERF_MP + HeapProfilerStart("gperf.srs.gmp"); #endif -#ifdef SRS_GPERF_CPU_PROFILE - ProfilerStart("gperf.srs.prof"); +#ifdef SRS_GPERF_CP + ProfilerStart("gperf.srs.gcp"); #endif signal(SIGNAL_RELOAD, handler); @@ -67,6 +67,16 @@ int main(int argc, char** argv) if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { return ret; } + +#ifdef SRS_GPERF_MC + #ifdef SRS_GPERF_MP + srs_error("option --with-gmc confict with --with-gmp, " + "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\n" + "Note that since the heap-checker uses the heap-profiling framework internally, " + "it is not possible to run both the heap-checker and heap profiler at the same time"); + return -1; + #endif +#endif if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) { return ret;