提交 a579a9ea 编写于 作者: D Dong Li 提交者: GitHub

build: added `bash apollo.sh build_prof` option to support profiling (#600)

* start app (e.g., planning) with profiling by `bash scripts/planning.sh start_prof`
上级 505f3931
......@@ -519,6 +519,7 @@ function print_usage() {
${BLUE}build_opt_gpu${NONE}: build optimized binary with Caffe GPU mode support
${BLUE}build_fe${NONE}: compile frontend javascript code, this requires all the node_modules to be installed already
${BLUE}build_no_perception${NONE}: run build build skip building perception module, useful when some perception dependencies are not satisified, e.g., CUDA, CUDNN, LIDAR, etc.
${BLUE}build_prof${NONE}: build for gprof support.
${BLUE}buildify${NONE}: fix style of BUILD files
${BLUE}check${NONE}: run build/lint/test, please make sure it passes before checking in new code
${BLUE}clean${NONE}: run Bazel clean
......@@ -553,6 +554,10 @@ function main() {
DEFINES="${DEFINES} --cxxopt=-DCPU_ONLY"
apollo_build_dbg $@
;;
build_prof)
DEFINES="${DEFINES} --cxxopt=-DCPU_ONLY  --copt='-pg' --cxxopt='-pg' --linkopt='-pg'"
apollo_build_dbg $@
;;
build_no_perception)
DEFINES="${DEFINES} --cxxopt=-DCPU_ONLY"
NOT_BUILD_PERCEPTION=true
......
......@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y \
software-properties-common \
unzip \
vim \
google-perftools \
wget \
zip
......
......@@ -277,6 +277,7 @@ void Planning::RunOnce() {
}
void Planning::Stop() {
AERROR << "Planning Stop is called";
last_publishable_trajectory_.reset(nullptr);
frame_.reset(nullptr);
planner_.reset(nullptr);
......
......@@ -227,6 +227,36 @@ function start() {
fi
}
function start_prof() {
MODULE=$1
shift
echo "Make sure you have built with 'bash apollo.sh build_prof'"
LOG="${APOLLO_ROOT_DIR}/data/log/${MODULE}.out"
is_stopped "${MODULE}"
if [ $? -eq 1 ]; then
PROF_FILE="/tmp/$MODULE.prof"
rm -rf $PROF_FILE
BINARY=${APOLLO_BIN_PREFIX}/modules/${MODULE}/${MODULE}
eval "CPUPROFILE=$PROF_FILE $BINARY \
--flagfile=modules/${MODULE}/conf/${MODULE}.conf \
--log_dir=${APOLLO_ROOT_DIR}/data/log $@ </dev/null >${LOG} 2>&1 &"
sleep 0.5
is_stopped "${MODULE}"
if [ $? -eq 0 ]; then
echo -e "Launched module ${MODULE} in prof mode. \nExport profile by command:"
echo -e "${YELLOW}google-pprof --pdf $BINARY $PROF_FILE > ${MODULE}_prof.pdf${NO_COLOR}"
return 0
else
echo "Could not launch module ${MODULE}. Is it already built?"
return 1
fi
else
echo "Module ${MODULE} is already running - skipping."
return 2
fi
}
function start_fe() {
MODULE=$1
shift
......@@ -269,6 +299,9 @@ function run() {
start_fe)
start_fe $module "$@"
;;
start_prof)
start_prof $module "$@"
;;
stop)
stop $module
;;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册