Skip to content

[Repo Assist] perf: reduce allocations and increase stream copy buffer size in Helper.fs#214

Merged
SchlenkR merged 2 commits intomasterfrom
repo-assist/perf-stream-buffer-2026-03-8eaa80f895adb4f6
Mar 9, 2026
Merged

[Repo Assist] perf: reduce allocations and increase stream copy buffer size in Helper.fs#214
SchlenkR merged 2 commits intomasterfrom
repo-assist/perf-stream-buffer-2026-03-8eaa80f895adb4f6

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Mar 9, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Two small but meaningful performance improvements to Helper.fs:

  1. appendSection – eliminate unnecessary list/array allocations
    The previous implementation built an underline separator by allocating a list of integers, mapping to '-' chars, converting to an array, and then calling the String constructor. This allocates three short-lived heap objects (int list, char list, char[]) on every print call.

    Replaced with String('-', s.Length + 1) which directly constructs the string in a single allocation.

  2. copyToCallbackAsync – increase stream copy buffer from 1KB → 80KB
    The 1024-byte read/write buffer in copyToCallbackAsync means roughly 80× more system calls per MB of data transferred compared to the .NET standard default of 81920 bytes (used by Stream.CopyToAsync). This directly limits download throughput for large responses.

    Increased to 81920 bytes (80KB) to match the .NET platform default and reduce round-trips.

Test Status

✅ Build passes: dotnet build completed with 0 errors (4 pre-existing warnings unrelated to these changes).

No new tests were required — these changes preserve existing behaviour exactly; only buffer sizing and allocation strategy differ.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…ffer 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 <noreply@anthropic.com>
@SchlenkR
Copy link
Copy Markdown
Member

SchlenkR commented Mar 9, 2026

/repo-assist Please comment the 80KB change with a one-liner

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Mar 9, 2026

Commit pushed: 312beae

Generated by Repo Assist

@SchlenkR SchlenkR marked this pull request as ready for review March 9, 2026 14:17
@SchlenkR SchlenkR merged commit da0f78e into master Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant