Writing a .NET Core cross platform profiler in an hour
summary
Demonstrates a working native C++ .NET Core profiler that builds from one codebase for Windows and Linux using MSBuild shared items and clang on WSL, exports DllGetClassObject, implements ICorProfilerCallback and uses std::atomic for COM-style ref counting; loader is activated by CORECLR_ENABLE_PROFILING=1 plus CORECLR_PROFILER and CORECLR_PROFILER_PATH. The demo logs assembly loads, JIT start/stop, GC events and thread creation to files, instruments via JIT IL hooks, and runs successfully against a Mandelbrot GUI, a primes console app and an ASP.NET Kestrel site.
AI-written summary · about
chapters (18)
- 0:00Introduction to profiling
- 1:52What is a .NET profiler
- 4:00How profiling works in .NET Core
- 6:50Steps to load a profiler
- 10:07COM and the Platform Adaptation Layer
- 14:43Building for Windows and Linux
- 19:44Environment variables setup
- 20:45Code walkthrough: DLL entry points
- 24:17Project properties and compiler settings
- 27:07Common code and abstractions
- 29:15Demo: Profiling on Windows
- 34:36Demo: Profiling on Linux with WSL
- 39:56Core profiler class implementation
- 46:18Initialize method and event handling
- 51:57Challenges in cross-platform code
- 57:33Advanced profiling techniques
- 57:56Summary and future of profiling
- 59:41Q&A and resources
related talks
59mDebugging and Profiling .NET Core Apps on Linux
51mPushing C# to new places with NativeAOT
50mDiagnostic techniques for .NET running on Linux and within containers
44mHow Real is this Cross Platform .NET Thing Really?
47mSolving .NET performance issues
01h 01mHidden gems in .NET Core 3
50mWhy I'm Not Leaving .NET
55m.NET without Windows
