dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Delay formatting msbuild resources until they get consumed by a Stream #3599

Closed cdmihai closed 3 years ago

cdmihai commented 6 years ago

Formatted msbuild resource strings eventually get sent to loggers, which eventually write them to some stream. Most StreamWriters have overloads (or will have) for formatting. Therefore it is pointless to convert formatted resources into strings, if they're final resting place is some buffer anyway.

An interesting experiment would be to put the resource and its arguments into some struct, and then propagate that struct all the way into loggers, which then can format them directly into their streams / string builders / etc.

Building WebLargeCore with minimal verbosity creates 74mb of formatted resources:

image

And in a broader sense, we should look for cases where we strinbbuild or format strings just to then later put them in some buffer. Patterns that will help

rokonec commented 3 years ago

I believe most of this has been addressed by LazyFormattedBuildEventArgs. There was a bug related to minimal verbosity and improper usage of LazyFormattedBuildEventArgs - #5924

rokonec commented 3 years ago

Please reopen if it remains relevant.