profiling-api

작성자: nvidia

Kit 기반 C++ 및 Python 코드에 프로파일링 영역, 메트릭, 주석을 추가합니다. Carbonite 매크로(CARB_PROFILE_ZONE, CARB_PROFILE_FUNCTION, GPU 영역) 등을 다룹니다.

npx skills add https://github.com/nvidia/omniperf --skill profiling-api

Profiling API — Instrumenting Kit-Based Code

How to add profiling zones, metrics, and annotations to C++ and Python code in the Carbonite/Kit ecosystem. For capturing traces, see the profiling skill. For analyzing them, see nsys-analyze.

C++ Profiling Macros

Source: carb/profiler/Profile.h

Scope-Based Zone (most common)

#include <carb/profiler/Profile.h>
constexpr const uint64_t kProfilerMask = 1;

void myFunction() {
    CARB_PROFILE_ZONE(kProfilerMask, "My C++ function");
    doHeavyWork();  // zone closes automatically at scope exit (RAII)
}

Parameters: (maskOrChannel, zoneName, ...variadic_args)

  • No variadic args → ProfileZoneStatic (pre-registered, faster)
  • With variadic args → ProfileZoneDynamic (printf formatting)

Auto Function Name

void myFunction() {
    CARB_PROFILE_FUNCTION(kProfilerMask);
    // zone name = function's pretty-printed name
}

Manual Begin/End

auto zoneId = CARB_PROFILE_BEGIN(kProfilerMask, "Manual zone");
// ... work ...
CARB_PROFILE_END(kProfilerMask, zoneId);

Prefer RAII style (CARB_PROFILE_ZONE) over manual begin/end.

GPU Zones

Kit's RTX renderer uses query-based GPU zone capture:

auto gpuCtx = CARB_PROFILE_CREATE_GPU_CONTEXT("Vulkan GPU", cpuTs, gpuTs, gpuPeriod, "vulkan");
CARB_PROFILE_GPU_QUERY_BEGIN(kProfilerMask, gpuCtx, queryId, "RTX Render Pass");
// ... submit GPU commands ...
CARB_PROFILE_GPU_QUERY_END(kProfilerMask, gpuCtx, queryId);
CARB_PROFILE_GPU_SET_QUERY_VALUE(kProfilerMask, gpuCtx, queryId, gpuTimestamp);

Enable GPU zones in Tracy:

--/profiler/gpu/tracyInject/enabled=true
--/rtx/addTileGpuAnnotations=true

Python Profiling API

Decorator (simplest)

import carb.profiler

@carb.profiler.profile
def my_function():
    do_something()

Manual begin/end

carb.profiler.begin(1, "My Python operation")
# ... work ...
carb.profiler.end(1)

Full IProfiler Interface

profiler = carb.profiler.acquire_profiler_interface()

profiler.begin(mask, name)                      # zone start
profiler.end(mask)                              # zone end
profiler.set_capture_mask(mask) -> int          # returns previous mask
profiler.get_capture_mask() -> int
profiler.value_float(mask, value, name)         # Tracy Plot (float)
profiler.value_int(mask, value, name)           # Tracy Plot (int)
profiler.value_uint(mask, value, name)          # Tracy Plot (uint)
profiler.instant(mask, type, name)              # instant event
profiler.flow(mask, type, id, name)             # cross-thread flow
profiler.frame(mask, name)                      # frame marker
profiler.set_python_profiling_enabled(bool)     # toggle auto-profiling
profiler.is_python_profiling_enabled() -> bool

Types:

carb.profiler.InstantType.THREAD    # thread timeline
carb.profiler.InstantType.PROCESS   # process-wide timeline
carb.profiler.FlowType.BEGIN / END  # flow start/end

Profiler Mask

64-bit bitmask controlling which zones are captured: (zone_mask & capture_mask) != 0

constexpr uint64_t kCaptureMaskNone    = 0;              // nothing
constexpr uint64_t kCaptureMaskAll     = (uint64_t)-1;   // everything (default when no mask arg)
constexpr uint64_t kCaptureMaskDefault = uint64_t(1);    // bit 0
constexpr uint64_t kCaptureMaskProfiler = uint64_t(1) << 63; // profiler internals

If a zone uses mask 0, Carbonite treats it as kCaptureMaskDefault (1).

Workflow: Start with --/app/profilerMask=1 (major spans only, minimal overhead). If more detail needed, remove the arg (defaults to ALL). Always start coarse, then zoom in.

Profiler Channels

Higher-level abstraction over masks, toggled at runtime via settings:

Declaring a Channel (C++)

CARB_PROFILE_DECLARE_CHANNEL("myext.rendering", 1, true, g_myRenderingChannel);
CARB_PROFILE_ZONE(g_myRenderingChannel, "My rendering work");

Runtime Toggle

--/profiler/channels/<name>/enabled=true|false

Commonly disabled during benchmarks (too noisy):

--/profiler/channels/carb.events/enabled=false
--/profiler/channels/carb.tasking/enabled=false

Memory channels:

--/profiler/channels/cpu.memory/enabled=true
--/profiler/channels/cpu.virtualmemory/enabled=true
--/profiler/channels/graphics.memory/enabled=true

Tracy Plot Data (Numeric Metrics)

Record time-series values displayed as graphs in Tracy's Plot view.

C++

float gpuFrameTimeMs = 8.5f;
CARB_PROFILE_VALUE(gpuFrameTimeMs, 1, "GPU Frame Time (ms)");

int32_t triangleCount = 1500000;
CARB_PROFILE_VALUE(triangleCount, 1, "Triangle Count");

uint32_t gpuMemoryMB = 4096;
CARB_PROFILE_VALUE(gpuMemoryMB, 1, "GPU Memory (MB)");

int gpuIndex = 0;
CARB_PROFILE_VALUE(gpuFrameTimeMs, 1, "GPU %d Frame Time", gpuIndex);

Python

profiler.value_float(1, 8.5, "GPU Frame Time (ms)")
profiler.value_int(1, 1500000, "Triangle Count")
profiler.value_uint(1, 4096, "GPU Memory (MB)")

Event Annotations

Instant Events

// C++
CARB_PROFILE_EVENT(1, carb::profiler::InstantType::Thread, "Scene loading started");
CARB_PROFILE_EVENT(1, carb::profiler::InstantType::Process, "Phase transition: WARM -> BENCHMARK");
# Python
profiler.instant(1, carb.profiler.InstantType.THREAD, "Scene loading started")
profiler.instant(1, carb.profiler.InstantType.PROCESS, "Phase transition")

Display as Tracy messages (recommended):

--/plugins/carb.profiler-tracy.plugin/instantEventsAsMessages=true

command_macro.core Annotations

The omni.kit.command_macro.core extension auto-inserts [command_macro][Measurement] Start/End - <tag> events around benchmark measurements.

Automatic Python Function Capture

Capture all Python function calls without per-function instrumentation:

export CARB_PROFILING_PYTHON=1

Or programmatically:

profiler.set_python_profiling_enabled(True)

Performance warning: Significant overhead. Tracy file size ~4x larger (measured: 275MB → 1.2GB). Never use during benchmark measurement — only in the TRACY analysis phase.

Profiling Backend Summary

BackendPluginOutputBest For
CPU (ChromeTrace)carb.profiler-cpu.plugin.json/.gzOffline analysis, targeted captures
Tracycarb.profiler-tracy.plugin.tracy (live capture)Real-time flame graphs, GPU context, stats
NVTXcarb.profiler-nvtx.plugin.nsys-rep (via nsys)GPU kernels, CUDA/Vulkan analysis

CPU backend can be toggled on/off at runtime for targeted capture:

profiler.set_capture_mask(1)   # start
# ... section to profile ...
profiler.set_capture_mask(0)   # stop

nvidia의 다른 스킬

compileiq-debug
nvidia
무언가 잘못되었을 때 사용: Search()가 멈추거나, 모든 평가가 INVALID_SCORE를 반환하거나, 점수가 개선되지 않거나, 모든 설정이 동일한 숫자를 반환하거나, ptxas 오류 등이 발생할 때
create-github-pr
nvidia
gh CLI를 사용하여 GitHub 풀 리퀘스트를 생성합니다. 사용자가 새 PR을 만들거나, 코드 리뷰를 제출하거나, 풀 리퀘스트를 열고자 할 때 사용합니다. 트리거 키워드 -…
nemoclaw-maintainer-cross-issue-sweep
nvidia
다른 열린 이슈들을 스캔하여 주어진 PR이 함께 수정하거나 실수로 망가뜨릴 수 있는 이슈를 찾습니다. 인접 수정 기회와 모순 위험을 file:line…과 함께 출력합니다.
fhir-basics
nvidia
에이전트에게 FHIR R4 API의 작동 방식, 사용 가능한 리소스, 검색 매개변수를 사용한 쿼리 방법, 모든 응답 형식을 올바르게 파싱하는 방법을 가르칩니다…
compileiq-validate-result
nvidia
검색이 완료된 후, 속도 향상을 청구하거나 ACF를 발송하기 전에 사용합니다. dump_results CSV를 로드하고, 상위 K개 후보(단일 목표)를 추출합니다…
changelog-audit
nvidia
릴리스 전에 Warp CHANGELOG.md를 감사합니다: 누락된 항목 복구, 사용자 영향별 정렬, 항목 언어 다듬기, 줄 바꿈, (릴리스 브랜치 모드) 비교 업데이트…
maintain-dynamic-plugins
nvidia
NeMo Relay 동적 플러그인 로더, 매니페스트, Rust 네이티브 SDK, gRPC 워커 프로토콜, Python 워커 SDK, 문서, 테스트 및 릴리스 워크플로 커버리지를 유지 관리합니다.
dgx-diagnose
nvidia
일반적인 DGX Station GB300 문제 진단 — CUDA 충돌, 잘못된 GPU 타겟팅, vLLM/SGLang 컨테이너 버그, MIG 상태 문제, NVLink/Fabric Manager 오류,…