Conversation
统一调整Program.cs中PipeOptions的pauseWriterThreshold、resumeWriterThreshold和minimumSegmentSize,增大缓冲区容量和分段大小,优化数据传输性能,减少写入暂停与恢复频率
|
The following frameworks were updated, pinging maintainers: |
There was a problem hiding this comment.
Pull request overview
该 PR 通过统一调大 TouchSocket C# 基准程序中 PipeOptions 的阈值与分段大小,减少管道写入暂停/恢复频率并提升吞吐,以优化数据传输性能。
Changes:
- 上调
ReceivePipeOptions的pauseWriterThreshold/resumeWriterThreshold(约 1MB/512KB → 2MB/1MB) - 上调
SendPipeOptions的pauseWriterThreshold/resumeWriterThreshold(约 64KB/32KB → 128KB/64KB) - 将
minimumSegmentSize从 4096 提升到 8192(接收/发送统一)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs | 调大收发 PipeOptions 阈值与 segment size;注意接收 PipeOptions 参数缩进变得不一致 |
| frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs | 调大收发 PipeOptions 阈值与 segment size,以减少 backpressure 抖动 |
| frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs | 调大收发 PipeOptions 阈值与 segment size,用于提升传输性能 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pool: MemoryPool<byte>.Shared, | ||
| readerScheduler: PipeScheduler.Inline, | ||
| writerScheduler: PipeScheduler.Inline, | ||
| pauseWriterThreshold: 2 * 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); |
There was a problem hiding this comment.
The named-argument indentation in this PipeOptions call is significantly over-indented compared to the surrounding block (and compared to SendPipeOptions below), which makes the config hard to scan and looks accidental. Please reformat so the arguments are consistently indented (e.g., one level deeper than the "new PipeOptions(" line) or run the repo formatter.
| pool: MemoryPool<byte>.Shared, | |
| readerScheduler: PipeScheduler.Inline, | |
| writerScheduler: PipeScheduler.Inline, | |
| pauseWriterThreshold: 2 * 1024 * 1024, | |
| resumeWriterThreshold: 1024 * 1024, | |
| minimumSegmentSize: 8192, | |
| useSynchronizationContext: false); | |
| pool: MemoryPool<byte>.Shared, | |
| readerScheduler: PipeScheduler.Inline, | |
| writerScheduler: PipeScheduler.Inline, | |
| pauseWriterThreshold: 2 * 1024 * 1024, | |
| resumeWriterThreshold: 1024 * 1024, | |
| minimumSegmentSize: 8192, | |
| useSynchronizationContext: false); |
| pauseWriterThreshold: 2 * 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); |
There was a problem hiding this comment.
These PipeOptions thresholds were increased (e.g., receive pause/resume to 2MB/1MB and segment size to 8KB). Given SetMaxCount(1000000), this raises the worst-case amount of buffered data the server may allow per connection and can increase memory pressure/GC under load. Please add a short rationale (or link to benchmark results) and consider defining these values as named constants so they’re easy to tune consistently across the TouchSocket variants.
| pool: MemoryPool<byte>.Shared, | ||
| readerScheduler: PipeScheduler.Inline, | ||
| writerScheduler: PipeScheduler.Inline, | ||
| pauseWriterThreshold: 2 * 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); |
There was a problem hiding this comment.
These PipeOptions thresholds were increased (receive pause/resume to 2MB/1MB and segment size to 8KB). With SetMaxCount(1000000), this increases the maximum buffered data the transport may permit per connection and can amplify memory pressure/GC if many connections concurrently backlog. Please add a brief rationale (or benchmark numbers) and consider using named constants so this tuning stays consistent across the apps.
| pauseWriterThreshold: 2 * 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); |
There was a problem hiding this comment.
These PipeOptions thresholds were increased (receive pause/resume to 2MB/1MB and segment size to 8KB). With SetMaxCount(1000000), this increases the maximum buffered data the transport may permit per connection and can amplify memory pressure/GC if many connections concurrently backlog. Please add a brief rationale (or benchmark numbers) and consider using named constants so this tuning stays consistent across the apps.
统一调整Program.cs中PipeOptions的pauseWriterThreshold、resumeWriterThreshold和minimumSegmentSize,增大缓冲区容量和分段大小,优化数据传输性能,减少写入暂停与恢复频率