Profiling

Kit comes with a profiler interface to instrument your code (in both C++ and python) and multiple backends that implement that profiler interface: NVTX, Chrome Trace, Tracy.

Profiling Backends

Tracy

Download Tracy from github https://github.com/wolfpld/tracy/releases/tag/v0.7 (the currently supported version is 0.7.0). Run it and hit the “connect” button.

Run kit with:

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

Tracy should start capturing profiling events.

Chrome Trace

Run kit with:

kit.exe [your_configuration] \
    --/app/profilerBackend="cpu" \
    --/plugins/carb.profiler-cpu.plugin/saveProfile=true \
    --/app/profileFromStart=true \
    --/plugins/carb.profiler-cpu.plugin/compressProfile=false \
    --/plugins/carb.profiler-cpu.plugin/filePath="mytrace.ct.json"

That will produce mytrace.ct.json file.

Open Google Chrome browser, type in chrome://tracing/ in the address line, open that trace file.

Instrumenting Code

For 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 Function");

    // do hard work
}

For python code use the Carbonite Profiler bindings:

import carb.profiler

def myfunc():
    carb.profiler.begin(1, "Creating explicit image providers")

    # hard work

    carb.profiler.end(1)

Automatic Python Profiler: omni.kit.profile_python

Python has a sys.setprofile() to profile all function calls. Kit comes with an extension that hooks into it automatically and reports all events to carb.profiler. It is quite slow, so it is disabled by default.

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