Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ await service.SetupAsync(new TouchSocketConfig()
pool: MemoryPool<byte>.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);
Comment on lines +28 to 31
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.

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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.

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 =>
Expand Down
20 changes: 10 additions & 10 deletions frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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.

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 =>
Expand Down
Loading