Profiling

Kit-based applications come bundled with a profiler interface to instrument your code, for both C++ and Python. Multiple profiler backend implementations are supported:

  • NVTX

  • ChromeTrace

  • Tracy

Easy Start

  1. Enable the omni.kit.profiler.window extension.

  2. Press F5 to start profiling, then press F5 again to stop profiling and get a trace opened in Tracy.

Press F8 to open the profiler window, where you can perform additional operations such as enabling the Python profiler, browsing traces, etc.

All traces are saved into one folder (can be found in the Browse section of the profiler window). They can be viewed with either Tracy or Chrome (by navigating to chrome://tracing).

Note

Both F5 and F8 have an entry in the top menu.

Profiling Backends

Chrome Trace

Run the Kit-based application using the following settings to produce a trace file named mytrace.gz in the directory where the executable is located:

kit.exe [your_configuration] \
    --/app/profilerBackend="cpu" \
    --/app/profileFromStart=1 \
    --/plugins/carb.profiler-cpu.plugin/saveProfile=1 \
    --/plugins/carb.profiler-cpu.plugin/compressProfile=1 \
    --/plugins/carb.profiler-cpu.plugin/filePath="mytrace.gz"

Then, using the Google Chrome browser, navigate to chrome://tracing to open a trace file and explore areas of interest.

Tracy

Download Tracy from GitHub (the currently supported version is 0.7.8). Run it and click the “connect” button.

Run the Kit-based application using the following settings:

kit.exe [your_configuration] \
    --/app/profilerBackend="tracy" \
    --/app/profileFromStart=true

Tracy should start capturing profiling events.

You can also convert a chrome trace profile to Tracy format using import-chrome.exe tool it provides. There is a helper tool to do that in repo_kit_tools, it downloads Tracy from packman and opens any of those 3 formats:

repo tracetools tracy mytrace.gz
repo tracetools tracy mytrace.json
repo tracetools tracy mytrace.tracy

Instrumenting Code

To instrument C++ code, use the macros from the Carbonite Profiler, e.g.:

#include <carb/profiler/Profile.h>

constexpr const uint64_t kProfilerMask = 1;

void myfunc()
{
    CARB_PROFILE_ZONE(kProfilerMask, "My C++ function");

    // Do hard work here.
    // [...]
}

For Python code, use the Carbonite Profiler bindings:

import carb.profiler

# Using the decorator version:

@carb.profiler.profile
def foo():
    pass


# Using explicit begin/end statements:

def my_func():
    carb.profiler.begin(1, "My Python function")

    # Do hard work here.
    # [...]

    carb.profiler.end(1)

Automatic Python Profiler: omni.kit.profile_python

Python offers a sys.setprofile() method to profile all function calls. Kit-based applications come with an extension that hooks into it automatically and reports all events to carb.profiler. Since this profiling method has an impact on the runtime performance of the application, it is disabled by default.

kit.exe [your_configuration] \
    [profiler_backend_configuration] \
    --enable omni.kit.profile_python