msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Alter DrainPacketQueue to avoid async overhead

Open Erarndt opened this issue 6 months ago • 0 comments

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:

image image image image image image image image image

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.

Changes Made

Testing

Notes

Erarndt avatar May 28 '25 00:05 Erarndt