mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
support gperf memory check(gmc).
This commit is contained in:
parent
489a492e47
commit
741d6f97f6
6 changed files with 88 additions and 24 deletions
|
@ -451,12 +451,21 @@ fi
|
||||||
|
|
||||||
if [ $SRS_GPERF = YES ]; then
|
if [ $SRS_GPERF = YES ]; then
|
||||||
echo "#define SRS_GPERF" >> $SRS_AUTO_HEADERS_H
|
echo "#define SRS_GPERF" >> $SRS_AUTO_HEADERS_H
|
||||||
#echo "#define SRS_GPERF_CPU_PROFILE" >> $SRS_AUTO_HEADERS_H
|
|
||||||
#echo "#define SRS_GPERF_HEAP_PROFILE" >> $SRS_AUTO_HEADERS_H
|
|
||||||
echo "#define SRS_GPERF_HEAP_CHECK" >> $SRS_AUTO_HEADERS_H
|
|
||||||
else
|
else
|
||||||
echo "#undef SRS_GPERF" >> $SRS_AUTO_HEADERS_H
|
echo "#undef SRS_GPERF" >> $SRS_AUTO_HEADERS_H
|
||||||
echo "#undef SRS_GPERF_CPU_PROFILE" >> $SRS_AUTO_HEADERS_H
|
fi
|
||||||
echo "#undef SRS_GPERF_HEAP_PROFILE" >> $SRS_AUTO_HEADERS_H
|
if [ $SRS_GPERF_MC = YES ]; then
|
||||||
echo "#undef SRS_GPERF_HEAP_CHECK" >> $SRS_AUTO_HEADERS_H
|
echo "#define SRS_GPERF_MC" >> $SRS_AUTO_HEADERS_H
|
||||||
|
else
|
||||||
|
echo "#undef SRS_GPERF_MC" >> $SRS_AUTO_HEADERS_H
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_MP = YES ]; then
|
||||||
|
echo "#define SRS_GPERF_MP" >> $SRS_AUTO_HEADERS_H
|
||||||
|
else
|
||||||
|
echo "#undef SRS_GPERF_MP" >> $SRS_AUTO_HEADERS_H
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_CP = YES ]; then
|
||||||
|
echo "#define SRS_GPERF_CP" >> $SRS_AUTO_HEADERS_H
|
||||||
|
else
|
||||||
|
echo "#undef SRS_GPERF_CP" >> $SRS_AUTO_HEADERS_H
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -18,6 +18,9 @@ SRS_HTTP=RESERVED
|
||||||
SRS_RESEARCH=RESERVED
|
SRS_RESEARCH=RESERVED
|
||||||
SRS_UTEST=RESERVED
|
SRS_UTEST=RESERVED
|
||||||
SRS_GPERF=RESERVED
|
SRS_GPERF=RESERVED
|
||||||
|
SRS_GPERF_MC=RESERVED
|
||||||
|
SRS_GPERF_MP=RESERVED
|
||||||
|
SRS_GPERF_CP=RESERVED
|
||||||
# arguments
|
# arguments
|
||||||
SRS_JOBS=1
|
SRS_JOBS=1
|
||||||
|
|
||||||
|
@ -28,7 +31,9 @@ SRS_FFMPEG=YES
|
||||||
SRS_HTTP=YES
|
SRS_HTTP=YES
|
||||||
SRS_RESEARCH=NO
|
SRS_RESEARCH=NO
|
||||||
SRS_UTEST=YES
|
SRS_UTEST=YES
|
||||||
SRS_GPERF=NO
|
SRS_GPERF_MC=NO
|
||||||
|
SRS_GPERF_MP=NO
|
||||||
|
SRS_GPERF_CP=NO
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# parse options
|
# parse options
|
||||||
|
@ -56,7 +61,9 @@ do
|
||||||
--with-http) SRS_HTTP=YES ;;
|
--with-http) SRS_HTTP=YES ;;
|
||||||
--with-research) SRS_RESEARCH=YES ;;
|
--with-research) SRS_RESEARCH=YES ;;
|
||||||
--with-utest) SRS_UTEST=YES ;;
|
--with-utest) SRS_UTEST=YES ;;
|
||||||
--with-gperf) SRS_GPERF=YES ;;
|
--with-gmc) SRS_GPERF_MC=YES ;;
|
||||||
|
--with-gmp) SRS_GPERF_MP=YES ;;
|
||||||
|
--with-gcp) SRS_GPERF_CP=YES ;;
|
||||||
|
|
||||||
--without-ssl) SRS_SSL=NO ;;
|
--without-ssl) SRS_SSL=NO ;;
|
||||||
--without-hls) SRS_HLS=NO ;;
|
--without-hls) SRS_HLS=NO ;;
|
||||||
|
@ -64,7 +71,9 @@ do
|
||||||
--without-http) SRS_HTTP=NO ;;
|
--without-http) SRS_HTTP=NO ;;
|
||||||
--without-research) SRS_RESEARCH=NO ;;
|
--without-research) SRS_RESEARCH=NO ;;
|
||||||
--without-utest) SRS_UTEST=NO ;;
|
--without-utest) SRS_UTEST=NO ;;
|
||||||
--without-gperf) SRS_GPERF=NO ;;
|
--without-gmc) SRS_GPERF_MC=NO ;;
|
||||||
|
--without-gmp) SRS_GPERF_MP=NO ;;
|
||||||
|
--without-gcp) SRS_GPERF_CP=NO ;;
|
||||||
|
|
||||||
--jobs) SRS_JOBS=${value} ;;
|
--jobs) SRS_JOBS=${value} ;;
|
||||||
|
|
||||||
|
@ -101,7 +110,7 @@ if [ $help = yes ]; then
|
||||||
--with-ffmpeg enable transcoding with ffmpeg.
|
--with-ffmpeg enable transcoding with ffmpeg.
|
||||||
--with-research build the research tools.
|
--with-research build the research tools.
|
||||||
--with-utest build the utest for srs.
|
--with-utest build the utest for srs.
|
||||||
--with-gperf build srs with gperf tools.
|
--with-gmc build memory check for srs with gperf tools.
|
||||||
|
|
||||||
--without-ssl disable rtmp complex handshake.
|
--without-ssl disable rtmp complex handshake.
|
||||||
--without-hls disable hls, rtmp streaming only.
|
--without-hls disable hls, rtmp streaming only.
|
||||||
|
@ -109,7 +118,7 @@ if [ $help = yes ]; then
|
||||||
--without-ffmpeg disable the ffmpeg transcoding feature.
|
--without-ffmpeg disable the ffmpeg transcoding feature.
|
||||||
--without-research do not build the research tools.
|
--without-research do not build the research tools.
|
||||||
--without-utest do not build the utest for srs.
|
--without-utest do not build the utest for srs.
|
||||||
--without-gperf do not build srs with gperf tools.
|
--without-gmc do not build memory check for srs with gperf tools.
|
||||||
|
|
||||||
--jobs[=N] Allow N jobs at once; infinite jobs with no arg.
|
--jobs[=N] Allow N jobs at once; infinite jobs with no arg.
|
||||||
used for make in the configure, for example, to make ffmpeg.
|
used for make in the configure, for example, to make ffmpeg.
|
||||||
|
@ -146,10 +155,29 @@ if [ $SRS_UTEST = RESERVED ]; then
|
||||||
echo "you must specifies the utest, see: ./configure --help";
|
echo "you must specifies the utest, see: ./configure --help";
|
||||||
__check_ok=NO
|
__check_ok=NO
|
||||||
fi
|
fi
|
||||||
if [ $SRS_GPERF = RESERVED ]; then
|
if [ $SRS_GPERF_MC = RESERVED ]; then
|
||||||
echo "you must specifies the gperf, see: ./configure --help";
|
echo "you must specifies the gperf-mc, see: ./configure --help";
|
||||||
|
__check_ok=NO
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_MP = RESERVED ]; then
|
||||||
|
echo "you must specifies the gperf-mp, see: ./configure --help";
|
||||||
|
__check_ok=NO
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_CP = RESERVED ]; then
|
||||||
|
echo "you must specifies the gperf-cp, see: ./configure --help";
|
||||||
__check_ok=NO
|
__check_ok=NO
|
||||||
fi
|
fi
|
||||||
if [ $__check_ok = NO ]; then
|
if [ $__check_ok = NO ]; then
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# generate the group option: SRS_GPERF
|
||||||
|
if [ $SRS_GPERF_MC = YES ]; then
|
||||||
|
SRS_GPERF=YES
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_MP = YES ]; then
|
||||||
|
SRS_GPERF=YES
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_CP = YES ]; then
|
||||||
|
SRS_GPERF=YES
|
||||||
|
fi
|
||||||
|
|
22
trunk/configure
vendored
22
trunk/configure
vendored
|
@ -64,6 +64,8 @@ SrsFfmpegSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_FFMPEG = YES ]; then Sr
|
||||||
SrsHttpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP = YES ]; then SrsHttpSummaryColor="\$(GREEN)"; fi
|
SrsHttpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP = YES ]; then SrsHttpSummaryColor="\$(GREEN)"; fi
|
||||||
SrsResearchSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\$(GREEN)"; fi
|
SrsResearchSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_RESEARCH = YES ]; then SrsResearchSummaryColor="\$(GREEN)"; fi
|
||||||
SrsUtestSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\$(GREEN)"; fi
|
SrsUtestSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\$(GREEN)"; fi
|
||||||
|
SrsGperfSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\$(GREEN)"; fi
|
||||||
|
SrsGperfMCSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\$(GREEN)"; fi
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# makefile
|
# makefile
|
||||||
|
@ -91,6 +93,10 @@ default: bandwidth librtmp-sample utest
|
||||||
@echo -e " \$(GREEN)librtmp-sample: ./research/librtmp, the srs-librtmp client sample\$(BLACK)"
|
@echo -e " \$(GREEN)librtmp-sample: ./research/librtmp, the srs-librtmp client sample\$(BLACK)"
|
||||||
@echo -e " ${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info.\$(BLACK)"
|
@echo -e " ${SrsResearchSummaryColor}research: ./objs/research, api server, players, ts info.\$(BLACK)"
|
||||||
@echo -e " ${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\$(BLACK)"
|
@echo -e " ${SrsUtestSummaryColor}utest: ./objs/srs_utest, the utest for srs\$(BLACK)"
|
||||||
|
@echo -e " ${SrsGperfSummaryColor}gperf: gmc/gmp/gcp for srs, @see: \$(BLACK)"
|
||||||
|
@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 "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)"
|
@echo -e "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)"
|
||||||
|
|
||||||
help:
|
help:
|
||||||
|
@ -313,10 +319,20 @@ if [ $SRS_UTEST = YES ]; then
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
|
echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
|
||||||
fi
|
fi
|
||||||
if [ $SRS_GPERF = YES ]; then
|
if [ $SRS_GPERF_MC = YES ]; then
|
||||||
echo -e "${GREEN}gperf(mem leak detect, mem/cpu perf) for srs are builded${BLACK}"
|
echo -e "${GREEN}gmc(gperf memory check) for srs are builded${BLACK}"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}note: gperf(mem leak detect, mem/cpu perf) for srs are not builded${BLACK}"
|
echo -e "${YELLOW}note: gmc(gperf memory check) for srs are not builded${BLACK}"
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_MP = YES ]; then
|
||||||
|
echo -e "${GREEN}gmp(gperf memory profile) for srs are builded${BLACK}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}note: gmp(gperf memory profile) for srs are not builded${BLACK}"
|
||||||
|
fi
|
||||||
|
if [ $SRS_GPERF_CP = YES ]; then
|
||||||
|
echo -e "${GREEN}gcp(gperf cpu profile) for srs are builded${BLACK}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
|
|
@ -150,6 +150,7 @@ int SrsListener::cycle()
|
||||||
SrsServer::SrsServer()
|
SrsServer::SrsServer()
|
||||||
{
|
{
|
||||||
signal_reload = false;
|
signal_reload = false;
|
||||||
|
signal_gmc_stop = false;
|
||||||
|
|
||||||
srs_assert(_srs_config);
|
srs_assert(_srs_config);
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
@ -232,15 +233,18 @@ int SrsServer::cycle()
|
||||||
st_usleep(SRS_TIME_RESOLUTION_MS * 1000);
|
st_usleep(SRS_TIME_RESOLUTION_MS * 1000);
|
||||||
srs_update_system_time_ms();
|
srs_update_system_time_ms();
|
||||||
|
|
||||||
if (signal_reload) {
|
|
||||||
// for gperf heap checker,
|
// for gperf heap checker,
|
||||||
// @see: research/gperftools/heap-checker/heap_checker.cc
|
// @see: research/gperftools/heap-checker/heap_checker.cc
|
||||||
// if user interrupt the program, exit to check mem leak.
|
// if user interrupt the program, exit to check mem leak.
|
||||||
// but, if gperf, use reload to terminate the server,
|
// but, if gperf, use reload to ensure main return normally,
|
||||||
// for the SIGINT will cause core-dump.
|
// because directly exit will cause core-dump.
|
||||||
#ifdef SRS_GPERF
|
#ifdef SRS_GPERF_MC
|
||||||
|
if (signal_gmc_stop) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (signal_reload) {
|
||||||
signal_reload = false;
|
signal_reload = false;
|
||||||
srs_info("get signal reload, to reload the config.");
|
srs_info("get signal reload, to reload the config.");
|
||||||
|
|
||||||
|
@ -274,7 +278,16 @@ void SrsServer::on_signal(int signo)
|
||||||
{
|
{
|
||||||
if (signo == SIGNAL_RELOAD) {
|
if (signo == SIGNAL_RELOAD) {
|
||||||
signal_reload = true;
|
signal_reload = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SRS_GPERF_MC
|
||||||
|
if (signo == SIGINT) {
|
||||||
|
srs_trace("gmc is on, main cycle will terminate normally.");
|
||||||
|
signal_gmc_stop = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: handle the SIGINT, SIGTERM.
|
// TODO: handle the SIGINT, SIGTERM.
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ private:
|
||||||
std::vector<SrsConnection*> conns;
|
std::vector<SrsConnection*> conns;
|
||||||
std::vector<SrsListener*> listeners;
|
std::vector<SrsListener*> listeners;
|
||||||
bool signal_reload;
|
bool signal_reload;
|
||||||
|
bool signal_gmc_stop;
|
||||||
public:
|
public:
|
||||||
SrsServer();
|
SrsServer();
|
||||||
virtual ~SrsServer();
|
virtual ~SrsServer();
|
||||||
|
|
|
@ -53,10 +53,6 @@ void handler(int signo)
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_GPERF_HEAP_CHECK
|
|
||||||
// env HEAPCHECK=normal ./objs/srs -c srs.conf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SRS_GPERF_HEAP_PROFILE
|
#ifdef SRS_GPERF_HEAP_PROFILE
|
||||||
HeapProfilerStart("gperf.srs");
|
HeapProfilerStart("gperf.srs");
|
||||||
|
@ -66,6 +62,7 @@ int main(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
signal(SIGNAL_RELOAD, handler);
|
signal(SIGNAL_RELOAD, handler);
|
||||||
|
signal(SIGINT, handler);
|
||||||
|
|
||||||
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
|
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue