-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Very high memory consumption during build (4GB) with binary log enabled #2168
Comments
From @rynowak on June 4, 2017 1:5 Zooming in more specifically on the highest category, it looks like there's some truly large amounts of text that are being passed around as |
Yikes. Taking a look. |
First observation: working set is about 4X better if I remove the binary logger from the command line args. cc @KirillOsenkov |
From @KirillOsenkov on June 4, 2017 18:39 Ouch. Can you try and see if /bl:ProjectImports=None will make it better? Not sure which version of the binary logger you're using. |
I believe this version does not have that feature:
|
Can't find symbols, but I was able to take a look at the huge strings using windbg:
hugestring.txt:
Looks like each task parameter is logged as single system.string and there is a huge set of items being passed to a NuGet restore target, which all get concatenated to log as a single parameter. There are a bunch of these on the LOH.
|
There are multiple layers of perf issues here. This pattern of giant item-sets being passed around to represent nuget data probably has to go at some point. But I think the high-order bit is to investigate why these huge strings appear to be leaking, which is why I've moved this to msbuild for the next look. |
Thanks so much for your analysis @nguerrera. This is because we enable MSBUILDLOGTASKINPUTS. Maybe we should add a switch to disable it. Definitely a binary logger problem :( |
It's super useful to see task inputs in the viewer. Can you stream them to the log instead of making a big string for each of them? |
Also, is this just the inefficiency of LOH GC or is msbuild holding on to these strings unnecessarily? |
A few questions that will help us investigate: Can we isolate a command line that calls MSBuild and exhibits this behavior? How do I turn unit-tests off? Are we already seeing the memory growth during NuGet restore? Before the actual build starts? Is this all reusing a single builder for restore and then build? When and where is msbuild.rsp being regenerated? Thanks! |
This appears to be the contents of
|
That's what I'm seeing too. If I wanted to turn off the /bl switch in there, how do I do that? |
Seeing weirdness in this area: Looks like the _loggingQueue is holding onto a GB of stuff: |
You could turn off |
I'm seeing even worse memory problems if I use a diagnostic-level text log (5 GB commit size). So it's nothing specific to the binary logger. |
OK I have a change to the BinaryLogger that keeps memory consumption under 800 MB by processing the incoming events as quickly as possible and having a custom queue on the logger side. How do I turn off the tests? Build.cmd doesn't accept any parameters? |
@rynowak @nguerrera can you guys do me a favor?
and see what kind of difference this makes for you. Note the build duration and peak working set/commit memory. |
So this is super weird. Even if you use the same binary logger that's in the .dll, it still is different for me: Maybe I'm just not cleaning in between test runs? |
I found that I had to delete the artifacts directory to get a fair test. |
OK I now know why passing Here's the problem: when passing /bl we set the overall verbosity to Diagnostic here: And here if the verbosity is Diagnostic, we enable logTaskInputs: That's why using the file logger with diag verbosity results in 5GB usage as well. Without logging task inputs, the compressed binary log is ~25 MB (557 MB uncompressed). With logging task inputs, the compressed binary log is ~160 MB (3.5 GB uncompressed). |
Run |
Child node "19" exited prematurely.
error
#2164
Yes the workaround is to change this line: from:
to:
You'll need to replace the path to Microsoft.Build.dll on the build machine, I don't know how to do that from Powershell (what variable is available to find the location of MSBuild being used for the build?) |
#2164 does not reproduce when logger is removed so root cause is logging only for those failure. |
To fix memory consumption here we need to fix the following issues: |
I think the memory consumption is fixed by #6155. |
Awesome! Saw some tweets go by and decided to check if my bug was still open and if I could finally close it. 😀 |
From @rynowak on June 4, 2017 1:1
Apologies if this is not the right place. Please redirect me if you want me to put this info somewhere else.
/cc @rainersigwald
Repo Steps:
clone https://github.com/aspnet/Mvc
run build.cmd
dotnet --info
Here's a dump
dotnet.zip
Copied from original issue: dotnet/sdk#1299
The text was updated successfully, but these errors were encountered: