---
title: ".NET Continuous Profiler: Under the hood"
description: "Datadog's .NET continuous profiler runs in-process as native C++ and Rust code loaded through the CLR's ICorProfilerCallback interface."
url: "https://swe.quest/articles/net-continuous-profiler-under-the-hood-46b61cbffdef64a4"
canonical: "https://www.datadoghq.com/blog/engineering/dotnet-continuous-profiler/"
source: "Datadog Engineering"
published: "2024-01-09"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 9
tags: ["dotnet","performance","observability","runtimes"]
---

# .NET Continuous Profiler: Under the hood

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2024-01-09, 9 min read, Deep dive. Original: [https://www.datadoghq.com/blog/engineering/dotnet-continuous-profiler/](https://www.datadoghq.com/blog/engineering/dotnet-continuous-profiler/)

## Summary

Datadog's .NET continuous profiler runs in-process as native C++ and Rust code loaded through the CLR's ICorProfilerCallback interface. This avoids TraceEvent and sidecars, which would add GC pressure, complicate deployment and prevent synchronous handling of events like allocations. Separate CPU, wall time, exception, lock contention, allocation and live-heap profilers feed samples to a shared Rust aggregator, which merges samples with identical stacks and labels into .pprof files. A native loader multiplexes the single allowed profiler callback across Datadog products, compiler-generated frame names are cleaned up for readability, and the runtime version is detected by probing which ICorProfilerInfo interface version QueryInterface returns.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [.NET](https://swe.quest/tags/dotnet.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)

## Prerequisites

- .NET CLR basics ([easy posts on .NET](https://swe.quest/tags/dotnet.md?difficulty=easy))
- sampling profilers
- COM interfaces

## Keywords

Datadog, ICorProfilerCallback, ICorProfilerInfo, pprof, CLR, EventPipe, ETW, TraceEvent

## Related posts

- [.NET Continuous Profiler: CPU and wall time profiling](https://swe.quest/articles/net-continuous-profiler-cpu-and-wall-time-profiling-5dcdacf43942cb04.md): Datadog Engineering · 2024-02-13 · Hard · 10 min read · .NET, Performance engineering, Runtimes & VMs, Observability, Linux
  Datadog's .NET continuous profiler samples managed threads every 10 ms instead of relying on ETW, perf or enter/leave hooks, which cost too much for 24/7 production use.
- [.NET Continuous Profiler: Memory usage](https://swe.quest/articles/net-continuous-profiler-memory-usage-51d84deba820efcb.md): Datadog Engineering · 2024-05-20 · Hard · 9 min read · .NET, Memory management, Observability, Performance engineering, Runtimes & VMs
  Datadog's .NET continuous profiler measures memory in three ways.
- [.NET Continuous Profiler: Exception and lock contention](https://swe.quest/articles/net-continuous-profiler-exception-and-lock-contention-93247ad1a6e667eb.md): Datadog Engineering · 2024-04-04 · Hard · 8 min read · .NET, Performance engineering, Observability, Concurrency, Runtimes & VMs
  Datadog's .NET continuous profiler captures thrown exceptions through ICorProfilerCallback::ExceptionThrown and reads each exception's \_message field by resolving System.Exception's ClassID from CoreLib metadata and computing the field offset with GetClassLayout.
- [How we wrote a Python profiler](https://swe.quest/articles/how-we-wrote-a-python-profiler-397d52e3f1db71ec.md): Datadog Engineering · 2020-10-07 · Medium · 7 min read · Python, Performance engineering, Observability
  Datadog built an always-on statistical profiler for Python because deterministic profilers like cProfile can add 2-3x overhead, too much for production.
- [Strobelight: A profiling service built on open source technology](https://swe.quest/articles/strobelight-a-profiling-service-built-on-open-source-technology-6a094fead0e4b62a.md): Meta Engineering · 2025-01-21 · Medium · 12 min read · Performance engineering, Observability, Linux, Cost optimization, Compilers
  Strobelight is Meta's fleet-wide profiling orchestrator, running 42 profilers (mostly eBPF-based, plus ad-hoc bpftrace scripts) on every production host with safeguards against PMU counter conflicts, concurrency limits and queuing.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
