Optimize OperationBuilder.Write For MemoryPool On .Net Core 2.0 and Full Framework

Description

On .Net Core 2.0 and Full Framework, Stream doesn't have a ReadOnlySpan<byte> overload. As a result, in OperationBuilder so we're currently copying the entire span to another block of memory on the ArrayPool so we can call Write(byte[], int, int).

However, when the MemoryPool is used, it's typically backed under the covers by a byte[], and MemoryMarshal.TryGetArray can be used to extract an ArraySegment. Using this can cut out an ArrayPool allocation and a memory copy. We should test for this scenario and optimize for it.

Environment

None

Gerrit Reviews

None

Release Notes Description

None

Activity

Show:
Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Labels

Story Points

Components

Fix versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created April 12, 2019 at 12:44 PM
Updated April 24, 2020 at 8:23 PM
Resolved April 16, 2019 at 6:51 PM
Instabug