-
-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix native memory profiler #1451
Fix native memory profiler #1451
Conversation
Quick test after clone your branch and replace NuGet references: BenchmarkDotNet=v0.12.0.20200508-develop, OS=Windows 10.0.18362.418 (1903/May2019Update/19H1) Job=ShortRun InvocationCount=1 IterationCount=3
I'm using the following configuration: /// <summary>
/// Initializes a new instance of the <see cref="BenchmarkConfig"/> class.
/// </summary>
public BenchmarkConfig()
{
#if DEBUG
AddValidator(JitOptimizationsValidator.DontFailOnError);
#endif
AddJob(Job.ShortRun);
AddColumnProvider(DefaultConfig.Instance.GetColumnProviders().ToArray());
AddLogger(DefaultConfig.Instance.GetLoggers().ToArray());
AddExporter(PlainExporter.Default);
AddExporter(CsvExporter.Default);
AddExporter(MarkdownExporter.Default);
AddDiagnoser(MemoryDiagnoser.Default);
AddDiagnoser(new NativeMemoryProfiler());
} |
@jmmorato Is the result ok or not? |
Hey,
(I have removed unrelated columns). |
@jjolidon Big thanks! I will check it one more time ;) |
OH WAIT, I had the wrong version restored, it would seem. Clearing the nuget cache solved that. Sorry for my mistake... Your branch fixes the leak shown by my reproducer, thanks again for the work! BenchmarkDotNet=v0.12.0.20200508-develop, OS=Windows 10.0.14393.3595 (1607/AnniversaryUpdate/Redstone1) Job=ShortRun Force=True IterationCount=3
|
@jjolidon I have the same result. Thanks! |
Well... the result is not ok for me in terms of memory leak reported :P but after your fix I cannot ensure that the problem is not in my side without more investigation.
I'm creating a wrapper library (OpenDDSharp) over a C++ library (OpenDDS). Right now, the development environment is not easy to setup (I need to work on that), so I prefer to share with you a minimal reproducer using the already compiled NuGet package PerformanceTest.zip (You'll need to change the Benchmark.DotNet project references). I just discovered your great diagnoser few weeks ago and start to play around with it. I'm really interested in your fix and/or improvements, so anything I could do to help you just let me know. Thanks for your job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WojciechNagorski thank you for another great PR!
I would like to make sure that it's the simplest solution before I hit the merge button. Please reply to my question.
src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs
Outdated
Show resolved
Hide resolved
src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs
Outdated
Show resolved
Hide resolved
src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs
Outdated
Show resolved
Hide resolved
src/BenchmarkDotNet.Diagnostics.Windows/Tracing/NativeMemoryLogParser.cs
Show resolved
Hide resolved
…to task-fix-native-memory-profiler
…WojciechNagorski/BenchmarkDotNet into task-fix-native-memory-profiler
@adamsitnik I think it is ready for review. |
783ca8c
to
416247a
Compare
@adamsitnik Build passed |
…to task-fix-native-memory-profiler
…to task-fix-native-memory-profiler
I created the repo https://github.com/WojciechNagorski/NativeMemorySample that contains benchmarks that use native memory allocation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WojciechNagorski LGTM, big thanks for doing this!
@adamsitnik Thanks for review! |
This PR fixes #1427 for .Net Core and .Net Framework.
The following benchmark is problematic:
I don't know why but
new StackTrace()
causes different workings of the benchmark..Net Core
There are allocation (propably from JIT) between ActulaWorkStart and Stop :
It is a event of JIT of WorkloadActualStop method.
The following screen shows that that allocations do not come from our benchmark:
So I solved it by filtering events only from benchmark stacks. I wanted to fix it by running a benchmark twice but I got a different JIT event.
.NET Framework without fix
In this case, there are allocations between ActualWork Start and Stop.
But I don't know anything about the origin of these allocations.
.Net Framework with fix
I found a fix during analyzing the PerfView code. I don't know why but these allocations disappear after adding
ClrTraceEventParser.Keywords.JittedMethodILToNativeMap
Summary
I tested if using my repository https://github.com/WojciechNagorski/NativeMemorySample. If you want to check it you need to change references to a custom build of BenchmarkDotNet.