-
Notifications
You must be signed in to change notification settings - Fork 2k
优化(Program.cs):调整PipeOptions参数提升性能 #10793
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,21 +30,21 @@ await server.SetupAsync(new TouchSocketConfig() | |
| options.BufferOnDemand = false; | ||
|
|
||
| options.ReceivePipeOptions = new PipeOptions( | ||
| pool: MemoryPool<byte>.Shared, | ||
| readerScheduler: PipeScheduler.Inline, | ||
| writerScheduler: PipeScheduler.Inline, | ||
| pauseWriterThreshold: 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 512, | ||
| minimumSegmentSize: 4096, | ||
| useSynchronizationContext: false); | ||
| pool: MemoryPool<byte>.Shared, | ||
| readerScheduler: PipeScheduler.Inline, | ||
| writerScheduler: PipeScheduler.Inline, | ||
| pauseWriterThreshold: 2 * 1024 * 1024, | ||
| resumeWriterThreshold: 1024 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); | ||
|
Comment on lines
+33
to
+39
|
||
|
|
||
| options.SendPipeOptions = new PipeOptions( | ||
| pool: MemoryPool<byte>.Shared, | ||
| readerScheduler: PipeScheduler.Inline, | ||
| writerScheduler: PipeScheduler.Inline, | ||
| pauseWriterThreshold: 64 * 1024, | ||
| resumeWriterThreshold: 32 * 1024, | ||
| minimumSegmentSize: 4096, | ||
| pauseWriterThreshold: 128 * 1024, | ||
| resumeWriterThreshold: 64 * 1024, | ||
| minimumSegmentSize: 8192, | ||
| useSynchronizationContext: false); | ||
| }) | ||
| .ConfigureContainer(a => | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,21 +25,21 @@ public static void Main(string[] args) | |||||||||||||||||||||||||||||
| options.BufferOnDemand = false; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| options.ReceivePipeOptions = new PipeOptions( | ||||||||||||||||||||||||||||||
| pool: MemoryPool<byte>.Shared, | ||||||||||||||||||||||||||||||
| readerScheduler: PipeScheduler.Inline, | ||||||||||||||||||||||||||||||
| writerScheduler: PipeScheduler.Inline, | ||||||||||||||||||||||||||||||
| pauseWriterThreshold: 1024 * 1024, | ||||||||||||||||||||||||||||||
| resumeWriterThreshold: 1024 * 512, | ||||||||||||||||||||||||||||||
| minimumSegmentSize: 4096, | ||||||||||||||||||||||||||||||
| useSynchronizationContext: false); | ||||||||||||||||||||||||||||||
| pool: MemoryPool<byte>.Shared, | ||||||||||||||||||||||||||||||
| readerScheduler: PipeScheduler.Inline, | ||||||||||||||||||||||||||||||
| writerScheduler: PipeScheduler.Inline, | ||||||||||||||||||||||||||||||
| pauseWriterThreshold: 2 * 1024 * 1024, | ||||||||||||||||||||||||||||||
| resumeWriterThreshold: 1024 * 1024, | ||||||||||||||||||||||||||||||
| minimumSegmentSize: 8192, | ||||||||||||||||||||||||||||||
| useSynchronizationContext: false); | ||||||||||||||||||||||||||||||
|
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); | |
| pool: MemoryPool<byte>.Shared, | |
| readerScheduler: PipeScheduler.Inline, | |
| writerScheduler: PipeScheduler.Inline, | |
| pauseWriterThreshold: 2 * 1024 * 1024, | |
| resumeWriterThreshold: 1024 * 1024, | |
| minimumSegmentSize: 8192, | |
| useSynchronizationContext: false); |
Copilot
AI
Feb 20, 2026
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.
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.
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.
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.