Skip to content

Comments

优化(Program.cs):调整PipeOptions参数提升性能#10793

Open
RRQM wants to merge 1 commit intoTechEmpower:masterfrom
RRQM:master
Open

优化(Program.cs):调整PipeOptions参数提升性能#10793
RRQM wants to merge 1 commit intoTechEmpower:masterfrom
RRQM:master

Conversation

@RRQM
Copy link
Contributor

@RRQM RRQM commented Feb 20, 2026

统一调整Program.cs中PipeOptions的pauseWriterThreshold、resumeWriterThreshold和minimumSegmentSize,增大缓冲区容量和分段大小,优化数据传输性能,减少写入暂停与恢复频率

统一调整Program.cs中PipeOptions的pauseWriterThreshold、resumeWriterThreshold和minimumSegmentSize,增大缓冲区容量和分段大小,优化数据传输性能,减少写入暂停与恢复频率
Copilot AI review requested due to automatic review settings February 20, 2026 00:24
@github-actions
Copy link
Contributor

The following frameworks were updated, pinging maintainers:
touchsocket: @RRQM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 通过统一调大 TouchSocket C# 基准程序中 PipeOptions 的阈值与分段大小,减少管道写入暂停/恢复频率并提升吞吐,以优化数据传输性能。

Changes:

  • 上调 ReceivePipeOptionspauseWriterThreshold / resumeWriterThreshold(约 1MB/512KB → 2MB/1MB)
  • 上调 SendPipeOptionspauseWriterThreshold / 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.

Comment on lines +28 to +34
pool: MemoryPool<byte>.Shared,
readerScheduler: PipeScheduler.Inline,
writerScheduler: PipeScheduler.Inline,
pauseWriterThreshold: 2 * 1024 * 1024,
resumeWriterThreshold: 1024 * 1024,
minimumSegmentSize: 8192,
useSynchronizationContext: false);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +34
pauseWriterThreshold: 2 * 1024 * 1024,
resumeWriterThreshold: 1024 * 1024,
minimumSegmentSize: 8192,
useSynchronizationContext: false);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +39
pool: MemoryPool<byte>.Shared,
readerScheduler: PipeScheduler.Inline,
writerScheduler: PipeScheduler.Inline,
pauseWriterThreshold: 2 * 1024 * 1024,
resumeWriterThreshold: 1024 * 1024,
minimumSegmentSize: 8192,
useSynchronizationContext: false);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to 31
pauseWriterThreshold: 2 * 1024 * 1024,
resumeWriterThreshold: 1024 * 1024,
minimumSegmentSize: 8192,
useSynchronizationContext: false);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant