Skip to content

Commit

Permalink
Reduce the size of the pipe (#49270)
Browse files Browse the repository at this point in the history
- Use the pipe itself as the synchronization object
- Store the options instance as a way to reference shared settings
- Added a field to PipeOptions for storing if the Pool is the ArrayPool implementation of the MemoryPool
- Shrink PipeAwaitable in the common case
  - Move the ExecutionContext and SynchronizationContext into a typed called the SchedulingContext. These types are mostly used with async await and it's extremely rare to have to capture any of this state.
- Shrink the size of PipeCompletion
  - Since completion callbacks are deprecated they are rarely set. We remove the pool and the other fields and just store a list (which should be rarely used now).
- Reduce the default segment pool size to 4 items = 16K buffered
  - The original size was optimized to avoid pool resizes but we need to balance idle memory and the potential resize cost of the resize.
  • Loading branch information
davidfowl authored Mar 8, 2021
1 parent acbbb50 commit 108d828
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(CommonPath)System\Threading\Tasks\TaskToApm.cs"
Link="Common\System\Threading\Tasks\TaskToApm.cs" />
Link="Common\System\Threading\Tasks\TaskToApm.cs" />
<Compile Include="Properties\InternalsVisibleTo.cs" />
<Compile Include="System\IO\Pipelines\BufferSegment.cs" />
<Compile Include="System\IO\Pipelines\CompletionData.cs" />
Expand Down Expand Up @@ -48,7 +48,7 @@
<Compile Include="System\IO\Pipelines\ThreadPoolScheduler.netstandard.cs" />
<Compile Include="System\IO\Pipelines\CancellationTokenExtensions.netstandard.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or
$(TargetFramework.StartsWith('net4'))">
<PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
Expand Down
Loading

0 comments on commit 108d828

Please sign in to comment.