msbuild
msbuild copied to clipboard
Alter DrainPacketQueue to avoid async overhead
Context
There's a meaningful degree of overhead in how async is being used in DrainPacketQueue that can be avoided by switching to a dedicated thread to handle the processing. There are multiple types that are being allocated as part of the async infrastructure:
These are some of the types that are being allocated as part of the async infrastructure and are absent from the after trace. The trace indicates that there's roughly a 75MB reduction in allocations in this path in total.
One note: I haven't measured an appreciable change in build times, but I am seeing some additional contention crop up in BuildManager.PendBuildRequest() with this change. Since it's in an unrelated path, my suspicion is that DrainPacketQueue() is moving faster and causing the additional contention. I have a change prepped to address this that I'll submit a separate PR for.