Repository navigation
dotnet-gcdump - #581
dotnet-gcdump#581
Conversation
|
CC @davidfowl |
|
cc @brianrob |
| try | ||
| { | ||
| output = string.IsNullOrEmpty(output) ? | ||
| $"{DateTime.Now.ToString(@"yyyyMMdd\_hhmmss")}_{processId}.gcdump" : |
There was a problem hiding this comment.
Tell me we're going to fix dotnet-trace as well 😄
sywhang
left a comment
There was a problem hiding this comment.
left some more comments. Is there any plan to add tests? :D
I'm planning on writing some manual testing scripts for now, and eventually automating them via #571. The manual testing will involve creating 2 gcdumps of an app that has a known quantity of specific object types in various configurations (local, static, pinned, etc.), then validating that the 2 dumps show the same counts and that the counts match what's expected. This is how I've been locally testing this tool. |
|
Sounds good. And thanks for letting me know about your plans to use #571 - I'll keep that in mind when implementing it. |
noahfalk
left a comment
There was a problem hiding this comment.
Yey! Looks good apart from some misc comments.
* NOTE: use this commit as baseline for file copied from Microsoft/PerfView
e857d0a to
333b89d
Compare
|
I've been using this to investigate dotnet/aspnetcore#13299, and just wanted to mention that once when doing Then I retried, and it worked. Update: I have now an instance on which I'm consistently getting this exception even if I wait and try again. |
|
@markvincze could you try running the tool with the |
|
@josalem it gives the following output. |
|
Thanks, that is very helpful! |
|
Have all of your gcdumps been taking 40-ish seconds? |
|
@josalem not really, these failing ones only take 1-2 seconds, but I think the earlier successful ones were also faster than 40s. |
|
@josalem I realized I didn't answer the second part of your question. |
noahfalk
left a comment
There was a problem hiding this comment.
LGTM, modulo a few more comments
| } | ||
| else | ||
| { | ||
| throw new ApplicationException("EventPipe session for gcDumpSession failed"); |
There was a problem hiding this comment.
For practical purposes this is probably fine so I'm not going to complain if you leave it as-is, but if we needed to be rigorous there are problems lurking here:
a) If cancellation happens quickly enough gcDumpSession will be null by design and that shouldn't be an error.
b) gcDumpSession is being modified on one thread and read on another without any locks. In a race condition thread 1 could write a non-null value but here on thread 2 a null value could still be observed. This would lead to the exception being thrown instead of the correct EndSession() being called.
c) This exception appears to mask whatever the real issue was that caused gcDumpSession to be null. Ideally the code would wait on readerTask to ensure that any exception thrown from readerTask is what propagates here.
There was a problem hiding this comment.
I refactored this a bit to remove some of the multi-threading and hiding of errors. I'll ping again for another look. The fixes got rid of a race that I found while refactoring.
|
Failures appear to be due to Mac failing to build SOS native dependencies and unrelated to this tool. CC @mikem8361 |
* Switch to a static function on Stopwatch to avoid multi-threading concerns with Stopwatch.Elapsed * Change tool name when writing memory graph * Add explicit null check on gcDumpSession to catch NRE in the event EventPipe failed to connect. * Add comment in README about future of code shared with PerfView * Refactor to remove wrapping task for type flush session * make EventPipeSession disposable to ensure stream is closed in case of exception in the reader * add using statements around source.Process calls * add additional logging to verbose log * Add additional logging * add timeout option * Remove unnecessary using statements * Update src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs Co-Authored-By: Noah Falk <[email protected]> * Update src/Tools/dotnet-gcdump/DotNetHeapDump/README.md Co-Authored-By: Noah Falk <[email protected]> * Fix weird unintended docs change * Refactor to reduce multi-threading * use cancellation token to cancel tasks on ctrl-c * swallow TaskCancellationExceptions * use volatile members for bools that are used between threads * Check dump status on return to amke sure we don't throw additional errors if event collection fails * fix last whitespace issue
6cabe92 to
d415599
Compare
|
Manually squashed changes in order to keep a separate commit for code copied from Microsoft/PerfView. |
Adds the
dotnet-gcdumptool. The spec for this tool is in another PR (#512).This PR includes some code that has been copied from Microsoft/PerfView. The reasoning is in the README that is included in the directory they were copied to. To sum it up, the refactoring required to expose these classes via TraceEvent was turning into more of a hassle than it was worth. There were diamond dependencies and target framework conflicts that would have been very disruptive to TraceEvent.
This tool will only work with .NET Core 3.1-preview2 or newer (.NET 5).
If this tool is used with runtimes older than that, then only the first gcdump will be viable. All subsequent dumps will be missing type information due to an issue in the runtime. Additionally, older runtimes will be missing COM and static types in the dump.
The output files can be opened in VS or PerfView. Opening multiple gcdumps in VS allows you to compare the heap stats over time.
CC - @tommcdon @caslan @shirhatti