dotnet / BenchmarkDotNet

Powerful .NET library for benchmarking
https://benchmarkdotnet.org
MIT License
10.24k stars 952 forks source link

DotMemoryDiagnoser implementation #2549

Closed martinothamar closed 3 months ago

martinothamar commented 3 months ago

Implements DotMemoryDiagnoser to match DotTraceDiagnoser

Sample output of IntroDotMemoryDiagnoser

image

martinothamar commented 3 months ago

There was a segfault happening for the integration test that I don't quite understand. I can no longer reproduce it after the last commit. I tried to debug some dumps locally but was unable to find relevant exceptions, so my only guess atm is that the crash originates from unmanaged code. Since changing the init logic seemed to affect things, and the crash always happening during InProcessEmitToolchain, I'm guessing it has something to do with attaching/detaching multiple times in the same process or something

In any case, I would like to test out using only the JetBrains API directly

martinothamar commented 3 months ago

The last commit simplifies the implementation of the tool by using only the Jetbrains API, and the lifetime of it is more clearly managed based on the incoming signals.

I'd be willing to try the same with dotTrace impl. I also want to make a flag like performExtraBenchmarksRun similar to some of the other profilers. I could do these en subsequent PRs

AndreyAkinshin commented 3 months ago

@martinothamar thank you very much for this PR!