Skip to content

royjacobson/externis

Repository files navigation

Externis

What is Externis?

Externis is a GCC plugin that generates profiling traces of the compilation process. The traces are viewable as a flame chart. It is inspired by clang's -ftime-trace feature.

The trace files generated by Externis are in the standard trace event format. They may be viewed in Google's Perfetto UI or in similar visualization tools.

Example

This image shows a trace file made by compiling a test from boost::geometry. The trace is viewed through Perfetto UI. You can download this example trace here and play with it yourself.

Example Flame Chart from compiling a test in boost::geometry

You will notice the larger blocks at the start. This is the time the compiler spends on pre-processing the needed headers. After that, there's a long time where the compiler spends time compiling each individual function, but each function itself doesn't take very long. At the end there are few large blocks that are the optimization passes, executed one-by-one on the whole translation unit.

Events shorter than 1ms are filtered out and not written to the trace, to save on disk space.

Building

The requirements for building Externis are:

  1. A GCC compiler supporting C++20. This plugin is tested with GCC11, but older versions might work as well.
  2. The GCC plugin headers. If you're using the GCC provided by your OS' package manager there's usually a package named gcc-plugin-devel or something similar to get the GCC plugin headers installed.
  3. CMake (but barely).

After downloading the source code, you can build and install the plugin into GCC's plugin directory with

mkdir build && cd build
cmake ..
make externis
sudo make install

Prebuilt binaries may be provided in the future.

Usage

After building the plugin, you can use it by passing the following additional arguments to GCC:

# If it's install to GCC's plugin folder
gcc <regular arguments> -fplugin=externis -fplugin-arg-externis-trace=SOME_PATH/trace.json
# Otherwise:
gcc <regular arguments> -fplugin=/PATH/TO/build/externis.so -fplugin-arg-externis-trace=SOME_PATH/trace.json

If a trace output path is not given, a temporary file with the name /tmp/trace_XXXXXX.json will be used instead.

License & Copyright

This plugin was written by Roy Jacobson and is released under the GPLv3 license.

The example trace file is a derived work of boost and provided under the Boost Software License.

Releases

No releases published

Packages

No packages published