Difference between the debug build and the optimized build

1,692 views
Skip to first unread message

Chui Hui Chiu

unread,
Dec 22, 2013, 12:26:33 PM12/22/13
to ns-3-users
Hello,

How are the two versions compiled?  With what compilation flags?  In what file are those flags specified?

Many thanks,
Chui-hui

Tommaso Pecorella

unread,
Dec 22, 2013, 1:00:14 PM12/22/13
to ns-3-...@googlegroups.com
Hi,

all the options are available in the help.

14:48:21:~/Development/workspace/ns-3-dev pecos$ ./waf --help
waf [commands] [options]

Main commands (example: ./waf build -j4)
  build    : executes the build
  check    : run the equivalent of the old ns-3 unit tests using test.py
  clean    : cleans the project
  configure: configures the project
  dist     : makes a tarball for redistributing the sources
  distcheck: checks if the project compiles (tarball from 'dist')
  docs     : build all the documentation: doxygen, manual, tutorial, models
  doxygen  : do a full build, generate the introspected doxygen and then the doxygen
  install  : installs the targets on the system
  list     : lists the targets to execute
  shell    : run a shell with an environment suitably modified to run locally built programs
  sphinx   : build the Sphinx documentation: manual, tutorial, models
  step     : executes tasks in a step-by-step fashion, for debugging
  uninstall: removes the targets installed
  update   : updates the plugins from the *waflib/extras* directory

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -j JOBS, --jobs=JOBS  amount of parallel jobs (8)
  -k, --keep            keep running happily even if errors are found
  -v, --verbose         verbosity level -v -vv or -vvv [default: 0]
  --nocache             ignore the WAFCACHE (if set)
  --zones=ZONES         debugging zones (task_gen, deps, tasks, etc)
  -d BUILD_PROFILE, --build-profile=BUILD_PROFILE
                        Specify the build profile.  Build profiles control the default compilation flags used for C/C++ programs, if CCFLAGS/CXXFLAGS are not set set in the environment. [Allowed Values: 'debug', 'release', 'optimized']
  --cwd=CWD_LAUNCH      Set the working directory for a program.
  --enable-gcov         Enable code coverage analysis. WARNING: this option only has effect with the configure command.
  --no-task-lines       Don't print task lines, i.e. messages saying which tasks are being executed by WAF.  Coupled with a single -v will cause WAF to output only the executed commands, just like 'make' does by default.
  --lcov-report         Generate a code coverage report (use this option at build time, not in configure)
  --run=RUN             Run a locally built program; argument can be a program name, or a command starting with the program name.
  --visualize           Modify --run arguments to enable the visualizer
  --command-template=COMMAND_TEMPLATE
                        Template of the command used to run the program given by --run; It should be a shell command string containing %s inside, which will be replaced by the actual program.
  --pyrun=PYRUN         Run a python program using locally built ns3 python module; argument is the path to the python program, optionally followed by command-line options that are passed to the program.
  --valgrind            Change the default command template to run programs and unit tests with valgrind
  --shell               DEPRECATED (run ./waf shell)
  --enable-sudo         Use sudo to setup suid bits on ns3 executables.
  --enable-tests        Build the ns-3 tests.
  --disable-tests       Do not build the ns-3 tests.
  --enable-examples     Build the ns-3 examples.
  --disable-examples    Do not build the ns-3 examples.
  --check               DEPRECATED (run ./test.py)
  --enable-static       Compile NS-3 statically: works only on linux, without python
  --enable-mpi          Compile NS-3 with MPI and distributed simulation support
  --doxygen-no-build    Run doxygen to generate html documentation from source comments, but do not wait for ns-3 to finish the full build.
  --enable-rpath        Link programs with rpath (normally not needed, see  --run and --shell; moreover, only works in some specific platforms, such as Linux and Solaris)
  --enable-modules=ENABLE_MODULES
                        Build only these modules (and dependencies)
  --boost-includes=BOOST_INCLUDES
                        path to the boost includes root (~boost root)                                    e.g. /path/to/boost_1_47_0
  --boost-libs=BOOST_LIBS
                        path to the directory where the boost libs are                                    e.g. /path/to/boost_1_47_0/stage/lib
  --boost-static        link with static boost libraries (.lib/.a)
  --boost-mt            select multi-threaded libraries
  --boost-abi=BOOST_ABI
                        select libraries with tags (dgsyp, d for debug),                                    see doc Boost, Getting Started, chapter 6.1
  --boost-linkage_autodetect
                        auto-detect boost linkage options (don't get used to it / might break other stuff)
  --boost-toolset=BOOST_TOOLSET
                        force a toolset e.g. msvc, vc90,                                                gcc, mingw, mgw45 (default: auto)
  --boost-python=BOOST_PYTHON
                        select the lib python with this version                                                 (default: 27)
  --with-brite=WITH_BRITE
                        Use BRITE integration support, given by the indicated path, to allow the use of the BRITE topology generator
  --with-nsclick=WITH_NSCLICK
                        Path to Click source or installation prefix for NS-3 Click Integration support
  --disable-nsclick     Disable NS-3 Click Integration support
  --disable-gtk         Disable GTK+ support
  --int64x64-as-double  Whether to use a double floating point type for int64x64 values WARNING: this option only has effect with the configure command.
  --disable-pthread     Whether to enable the use of POSIX threads
  --force-planetlab     Forces compilation of PlanetLab even if not suported by the local system
  --with-nsc=WITH_NSC   Use Network Simulation Cradle, given by the indicated path, to allow the use of real-world network stacks
  --with-openflow=WITH_OPENFLOW
                        Path to OFSID source for NS-3 OpenFlow Integration support
  --nopyc               Do not install bytecode compiled .pyc files (configuration) [Default:install]
  --nopyo               Do not install optimised compiled .pyo files (configuration) [Default:install]
  --disable-python      Don't build Python bindings.
  --apiscan=MODULE[,MODULE...]
                        Rescan the API for the indicated module(s), for Python bindings.  Needs working GCCXML / pygccxml environment.  The metamodule 'all' expands to all available ns-3 modules.
  --with-pybindgen=WITH_PYBINDGEN
                        Path to an existing pybindgen source tree to use.
  --with-python=WITH_PYTHON
                        Path to the Python interpreter to use.

  configure options:
    -o OUT, --out=OUT   build dir for the project
    -t TOP, --top=TOP   src dir for the project
    --download          try to download the tools if missing

  build and install options:
    -p, --progress      -p: progress bar; -pp: ide output
    --targets=TARGETS   task generators, e.g. "target1,target2"

  step options:
    --files=FILES       files to process, by regexp, e.g. "*/main.c,*/test/main.o"

  install/uninstall options:
    -f, --force         force file installation
    --distcheck-args=DISTCHECK_ARGS
                        arguments to pass to distcheck

  C Compiler Options:
    --check-c-compiler=CHECK_C_COMPILER
                        On this platform (darwin) the following C-Compiler will be checked by default: "gcc"

  C++ Compiler Options:
    --check-cxx-compiler=CHECK_CXX_COMPILER
                        On this platform (darwin) the following C++ Compiler will be checked by default: "g++"

  Installation directories:
    By default, "waf install" will put the files in "/usr/local/bin", "/usr/local/lib" etc. An installation prefix other than "/usr/local" can be given using "--prefix", for example "--prefix=$HOME"

    --prefix=PREFIX     installation prefix [default: '/usr/local/']
    --destdir=DESTDIR   installation root [default: '']
    --exec-prefix=EXEC_PREFIX
                        installation prefix [Default: ${PREFIX}]

  Pre-defined installation directories:
    --bindir=BINDIR     user executables [Default: ${EXEC_PREFIX}/bin]
    --sbindir=SBINDIR   system admin executables [Default: ${EXEC_PREFIX}/sbin]
    --libexecdir=LIBEXECDIR
                        program executables [Default: ${EXEC_PREFIX}/libexec]
    --sysconfdir=SYSCONFDIR
                        read-only single-machine data [Default: ${PREFIX}/etc]
    --sharedstatedir=SHAREDSTATEDIR
                        modifiable architecture-independent data [Default: ${PREFIX}/com]
    --localstatedir=LOCALSTATEDIR
                        modifiable single-machine data [Default: ${PREFIX}/var]
    --libdir=LIBDIR     object code libraries [Default: ${EXEC_PREFIX}/lib]
    --includedir=INCLUDEDIR
                        C header files [Default: ${PREFIX}/include]
    --oldincludedir=OLDINCLUDEDIR
                        C header files for non-gcc [Default: /usr/include]
    --datarootdir=DATAROOTDIR
                        read-only arch.-independent data root [Default: ${PREFIX}/share]
    --datadir=DATADIR   read-only architecture-independent data [Default: ${DATAROOTDIR}]
    --infodir=INFODIR   info documentation [Default: ${DATAROOTDIR}/info]
    --localedir=LOCALEDIR
                        locale-dependent data [Default: ${DATAROOTDIR}/locale]
    --mandir=MANDIR     man documentation [Default: ${DATAROOTDIR}/man]
    --docdir=DOCDIR     documentation root [Default: ${DATAROOTDIR}/doc/${PACKAGE}]
    --htmldir=HTMLDIR   html documentation [Default: ${DOCDIR}]
    --dvidir=DVIDIR     dvi documentation [Default: ${DOCDIR}]
    --pdfdir=PDFDIR     pdf documentation [Default: ${DOCDIR}]
    --psdir=PSDIR       ps documentation [Default: ${DOCDIR}]
18:53:09:~/Development/workspace/ns-3-dev pecos$ 

To switch from debug (the default) to optimized, the correct flag is:
  -d BUILD_PROFILE, --build-profile=BUILD_PROFILE
                        Specify the build profile.  Build profiles control the default compilation flags used for C/C++ programs, if CCFLAGS/CXXFLAGS are not set set in the environment. [Allowed Values: 'debug', 'release', 'optimized']

The obvious difference is that the debug symbols are only available in "debug" configurations. Between "release" and "optimized", there's a higher level of optimization in C++ code.
The other visible difference is that NS_LOG macros are only active in debug build. As a consequence, the optimized build will not print anything, unless you use cout (but you don't want messages in the console in an optimized build).

The flags you choose are saved somewhere in the Waf configuration files, but it's not a good idea to change them there, as they're re-created on the fly. Let waf do its work.

Cheers,

T.

Chui Hui Chiu

unread,
Dec 22, 2013, 1:07:01 PM12/22/13
to ns-3-users
Thank you for your prompt reply!

Is there any performance evaluation for the 3 build profiles?

Thanks,
Chui-hui


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/groups/opt_out.

Tommaso Pecorella

unread,
Dec 22, 2013, 1:34:51 PM12/22/13
to ns-3-...@googlegroups.com
Nope, as it depends on the simulation you're running. Some do benefit incredibly from optimized builds, some much less.

In one of my simulations, which I guess it's a pretty extreme case, I went from 7 minutes to 50 seconds. So around 1 order of magnitude.
However, don't expect always these numbers. It really depends on the amount of output files and how the optimization can "work" with your code.

As a rule of thumb, to speedup the simulation remember to reduce the output to the bare minimum. E.g., disable the pcap / traces if you don't need 'em, don't do any cout or print (except the ones you really need), and so on.
Also, if you open files for writing, remember to *not* force flush them and leave it to the compiler.
basically, the good practices for any optimization build.

Cheers,

T.

Robert Ammon

unread,
Apr 14, 2017, 8:42:13 PM4/14/17
to ns-3-users
Tommaso

I am working with Tom Henderson on a project to set up NS-3 in a Visual Studio environment for Windows.  As such, I want to try and mimic the 3 build environments under Visual Studio.  I have created the three configurations but I need to try to match the optimizations done for the optimized build profile under WAF on Linux.  The differences will be for the GCC tool set under Linux knowing what the GCC tool set option differences under Linux will give me an idea of what to do under Visual Studio.  Can you point me to the place where these are specified in WAF, please.

Tom Henderson

unread,
Apr 15, 2017, 2:45:20 AM4/15/17
to ns-3-...@googlegroups.com
Robert,
You can find this information in the waf-tools/cflags.py file.

optimization level, warnings level and debug level are specified for
different build types, and get_optimization_flags() translates the
optimization levels to flags.

- Tom
Reply all
Reply to author
Forward
0 new messages