.NET Continuous Profiler: CPU and wall time profiling | Datadog
Feb 13, 2024Christophe Nasarre

Summary
This post details the implementation of CPU and wall time profiling in the Datadog .NET continuous profiler. It explains how application threads are monitored and sampled, including handling of managed and native threads. The implementation of CPU profiling involves sampling runnable threads and measuring their CPU consumption using OS-specific APIs (NtQueryInformationThread on Windows, /proc/self/task/<tid>/stat on Linux). The post also highlights an internal example where the CPU profiler was used to reduce CPU consumption by identifying a memory-intensive code path in the profiler itself.
More from the Java CPU Profiling trail
- How we built an async-aware Python profiler | Datadog
- Unbiased Java CPU profiling with JFR in JDK 25 | Datadog
- From hand-tuned Go to self-optimizing code: Building BitsEvolve | Datadog
- How we tracked down a Go 1.24 memory regression across hundreds of pods | Datadog
- .NET Continuous Profiler: Exception and lock contention | Datadog