Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce byte array allocations when reading/writing packets (#6023)
* Reduce byte array allocations when reading/writing packets Byte arrays are a major source of LOH allocations when streaming logging events across nodes. Allocating a large MemoryStream once and then growing it as needed almost completely removes allocations for byte arrays. This should significantly improve memory traffic during large builds. * Write the last part of the packet synchronously on Mono. If we use WriteAsync and don't await it, then subsequent WriteAsync may be called before the first continuation returns. If both calls share the same buffer and they overlap, we will overwrite the data in the buffer and cause junk to arrive at receiver. * Make SendData write packets asynchronously. This avoids blocking the main loop. Roughly equivalent to writing the packet asynchronously using fire-and-forget (BeginWrite).
- Loading branch information
1 parent
1a0d8e8
commit de3b887
Showing
2 changed files
with
119 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
de3b887
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this commit changed the encoding of the packet length header field from native byte order to always little-endian (which causes a problem on big-endian systems). See #6204 for more details.