C++ Optimization flags on an app using GStreamer

Hello,
I was wondering if I could optimize my C++ GStreamer application using common optimization flags like -01, -02 and -03 aswell as -0fast, and also profile-guided optimization (PGO) with -fprofile-use as well as link-time optimization using -flto (LTO) ?
Especially I was wondering if there are any dangers to this kind of optimization.

There is always a slight risk, but not as much as 20 years ago. What matter is that you test well your software while progressively enabling more aggressive optimization. On strategy is to locate your bottlenecks and to only do that on hot path, that will narrow your testing.

Is there any flags I could use when compiling GStreamer from source to switch on -O3, -march=native or -flto ? Or is this use case prohibited and I should just focus on using it on my app only ?

meson --prefix=/opt/gstreamer \
  -Dgpl=enabled \
  -Dvaapi=enabled \
  -Drs=disabled \
  -Dlibav=enabled \
  -Dgood=enabled \
  -Dbad=enabled \
  -Dugly=enabled \
  -Dges=enabled \
  -Drtsp_server=enabled \
  -Dbase=enabled \
  -Dlibnice=enabled \
  -Ddevtools=disabled \
  -Dtests=disabled \
  -Dexamples=disabled \
  -Ddoc=disabled \
  -Dorc=disabled \
  -Dlibsoup:sysprof=disabled \
  -Dbuildtype=release build

Have a look at the meson build documentation for that, you likely want to pass to the meson setup command, --buildtype=release (or debugoptimized) and set the optimization level --optimization=3.

1 Like

Thank you for the help !