From be2ec1b2af29d7919dd2e90974105d747f6146ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com> Date: Fri, 20 Feb 2026 08:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96(Program.cs):=E8=B0=83?= =?UTF-8?q?=E6=95=B4PipeOptions=E5=8F=82=E6=95=B0=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一调整Program.cs中PipeOptions的pauseWriterThreshold、resumeWriterThreshold和minimumSegmentSize,增大缓冲区容量和分段大小,优化数据传输性能,减少写入暂停与恢复频率 --- .../src/TouchSocketHttp/Program.cs | 12 +++++------ .../src/TouchSocketHttpPlatform/Program.cs | 20 +++++++++---------- .../src/TouchSocketWebApi/Program.cs | 20 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs index 46e388ae14a..9cac46e9ca6 100644 --- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs +++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs @@ -25,18 +25,18 @@ await service.SetupAsync(new TouchSocketConfig() pool: MemoryPool.Shared, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, - pauseWriterThreshold: 1024 * 1024, - resumeWriterThreshold: 1024 * 512, - minimumSegmentSize: 4096, + pauseWriterThreshold: 2 * 1024 * 1024, + resumeWriterThreshold: 1024 * 1024, + minimumSegmentSize: 8192, useSynchronizationContext: false); options.SendPipeOptions = new PipeOptions( pool: MemoryPool.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 => diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs index 93e85b0e202..993cf25d74a 100644 --- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs +++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs @@ -30,21 +30,21 @@ await server.SetupAsync(new TouchSocketConfig() options.BufferOnDemand = false; options.ReceivePipeOptions = new PipeOptions( - pool: MemoryPool.Shared, - readerScheduler: PipeScheduler.Inline, - writerScheduler: PipeScheduler.Inline, - pauseWriterThreshold: 1024 * 1024, - resumeWriterThreshold: 1024 * 512, - minimumSegmentSize: 4096, - useSynchronizationContext: false); + pool: MemoryPool.Shared, + readerScheduler: PipeScheduler.Inline, + writerScheduler: PipeScheduler.Inline, + pauseWriterThreshold: 2 * 1024 * 1024, + resumeWriterThreshold: 1024 * 1024, + minimumSegmentSize: 8192, + useSynchronizationContext: false); options.SendPipeOptions = new PipeOptions( pool: MemoryPool.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 => diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs index e1639a2b4c2..41af01f8e6d 100644 --- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs +++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs @@ -25,21 +25,21 @@ public static void Main(string[] args) options.BufferOnDemand = false; options.ReceivePipeOptions = new PipeOptions( - pool: MemoryPool.Shared, - readerScheduler: PipeScheduler.Inline, - writerScheduler: PipeScheduler.Inline, - pauseWriterThreshold: 1024 * 1024, - resumeWriterThreshold: 1024 * 512, - minimumSegmentSize: 4096, - useSynchronizationContext: false); + pool: MemoryPool.Shared, + readerScheduler: PipeScheduler.Inline, + writerScheduler: PipeScheduler.Inline, + pauseWriterThreshold: 2 * 1024 * 1024, + resumeWriterThreshold: 1024 * 1024, + minimumSegmentSize: 8192, + useSynchronizationContext: false); options.SendPipeOptions = new PipeOptions( pool: MemoryPool.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 =>