From 4e72c5565df9826cd35344c88061813041da6027 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 Mar 2026 12:53:42 +0000 Subject: [PATCH 1/2] perf: reduce allocations in appendSection and increase stream copy buffer size - Replace list-based underline creation with String('-', n) constructor to eliminate unnecessary list/array allocations in appendSection - Increase stream copy buffer from 1024 to 81920 bytes (matching .NET default for Stream.CopyToAsync) to improve download throughput Co-Authored-By: Claude Sonnet 4.6 --- src/FsHttp/Helper.fs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/FsHttp/Helper.fs b/src/FsHttp/Helper.fs index f8475352..3d6200ae 100644 --- a/src/FsHttp/Helper.fs +++ b/src/FsHttp/Helper.fs @@ -26,9 +26,7 @@ type StringBuilder with member sb.appendSection(s: string) = sb.appendLine s - - String([ 0 .. s.Length ] |> List.map (fun _ -> '-') |> List.toArray) - |> sb.appendLine + String('-', s.Length + 1) |> sb.appendLine [] module Map = @@ -96,7 +94,7 @@ module Stream = let copyToCallbackAsync (target: Stream) callback (source: Stream) = async { - let buffer = Array.create 1024 (byte 0) + let buffer = Array.create 81920 (byte 0) let logTimeSpan = TimeSpan.FromSeconds 1.5 let mutable continueLooping = true let mutable overallBytesCount = 0 From 312beaeb5ad4dcf8ed9497c59a212a4b0a006ae8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 Mar 2026 13:12:45 +0000 Subject: [PATCH 2/2] docs: add comment explaining 80KB buffer size matches .NET default --- src/FsHttp/Helper.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FsHttp/Helper.fs b/src/FsHttp/Helper.fs index 3d6200ae..c505f3bf 100644 --- a/src/FsHttp/Helper.fs +++ b/src/FsHttp/Helper.fs @@ -94,7 +94,7 @@ module Stream = let copyToCallbackAsync (target: Stream) callback (source: Stream) = async { - let buffer = Array.create 81920 (byte 0) + let buffer = Array.create 81920 (byte 0) // 80KB matches .NET's Stream.CopyToAsync default buffer size let logTimeSpan = TimeSpan.FromSeconds 1.5 let mutable continueLooping = true let mutable overallBytesCount = 0