Allow to build P4 tools without debug flags to improve BMv2 performance
If the env variable DEBUG_FLAGS is set to false, build tools without
debug features to improve throughput of BMv2 and reduce CPU/memory
footprint.
Debug features include BMv2 logging, debugger, nanomsg, etc.
With DEBUG_FLAGS=true, when running 20 BMv2 instances, it requires 4 CPU
cores 100%. With DEBUG_FLAGS=false, when running 50 BMv2 instances,
overall CPU usage is only 1%.
Change-Id: Ifdd8ea976940b440797beb0e2300a749a55907dd
diff --git a/tools/dev/p4vm/install-p4-tools.sh b/tools/dev/p4vm/install-p4-tools.sh
index 8807e06..9bf8840 100755
--- a/tools/dev/p4vm/install-p4-tools.sh
+++ b/tools/dev/p4vm/install-p4-tools.sh
@@ -28,6 +28,10 @@
NUM_CORES=`grep -c ^processor /proc/cpuinfo`
+# If false, build tools without debug features to improve throughput of BMv2 and
+# reduce CPU/memory footprint.
+DEBUG_FLAGS=${DEBUG_FLAGS:-true}
+
function do_requirements {
sudo apt update
sudo apt-get install -y --no-install-recommends \
@@ -259,7 +263,12 @@
./autogen.sh
# FIXME: re-enable --with-sysrepo when gNMI support becomes more stable
# ./configure --with-proto --with-sysrepo 'CXXFLAGS=-O0 -g'
- ./configure --with-proto 'CXXFLAGS=-O0 -g'
+ if [ "${DEBUG_FLAGS}" = true ] ; then
+ CONF_FLAGS="'CXXFLAGS=-O0 -g'"
+ else
+ CONF_FLAGS=""
+ fi
+ ./configure --with-proto ${CONF_FLAGS}
make -j${NUM_CORES}
sudo make install
sudo ldconfig
@@ -272,7 +281,12 @@
checkout_bmv2
./autogen.sh
- ./configure --enable-debugger --with-pi 'CXXFLAGS=-O0 -g'
+ if [ "${DEBUG_FLAGS}" = true ] ; then
+ CONF_FLAGS="--enable-debugger 'CXXFLAGS=-O0 -g'"
+ else
+ CONF_FLAGS="--disable-logging-macros --disable-elogger --without-nanomsg"
+ fi
+ ./configure --with-pi ${CONF_FLAGS}
make -j${NUM_CORES}
sudo make install
sudo ldconfig
@@ -281,9 +295,14 @@
cd targets/simple_switch_grpc
./autogen.sh
+ if [ "${DEBUG_FLAGS}" = true ] ; then
+ CONF_FLAGS="'CXXFLAGS=-O0 -g'"
+ else
+ CONF_FLAGS=""
+ fi
# FIXME: re-enable --with-sysrepo when gNMI support becomes more stable
# ./configure --with-sysrepo --with-thrift 'CXXFLAGS=-O0 -g'
- ./configure --with-thrift 'CXXFLAGS=-O0 -g'
+ ./configure --with-thrift ${CONF_FLAGS}
make -j${NUM_CORES}
sudo make install
sudo ldconfig