Skip to content

Commit da0f78e

Browse files
authored
Merge pull request #214 from fsprojects/repo-assist/perf-stream-buffer-2026-03-8eaa80f895adb4f6
[Repo Assist] perf: reduce allocations and increase stream copy buffer size in Helper.fs
2 parents 6d6b85f + 312beae commit da0f78e

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/FsHttp/Helper.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ type StringBuilder with
2626

2727
member sb.appendSection(s: string) =
2828
sb.appendLine s
29-
30-
String([ 0 .. s.Length ] |> List.map (fun _ -> '-') |> List.toArray)
31-
|> sb.appendLine
29+
String('-', s.Length + 1) |> sb.appendLine
3230

3331
[<RequireQualifiedAccess>]
3432
module Map =
@@ -96,7 +94,7 @@ module Stream =
9694

9795
let copyToCallbackAsync (target: Stream) callback (source: Stream) =
9896
async {
99-
let buffer = Array.create 1024 (byte 0)
97+
let buffer = Array.create 81920 (byte 0) // 80KB matches .NET's Stream.CopyToAsync default buffer size
10098
let logTimeSpan = TimeSpan.FromSeconds 1.5
10199
let mutable continueLooping = true
102100
let mutable overallBytesCount = 0

0 commit comments

Comments
 (0)