perf(webclient): increase I/O buffer sizes from 4KB to 32KB

Reduce Go-JS boundary crossings by 8x for large transfers. This affects ReadAll() in http_js.go and NewReadableStream() in stream_js.go. Impact: 256 context switches → 32 for 1MB transfers.

cognitive-glitch committed Dec 9, 2025 at 14:10 UTC 3e850428ccd7c23e9316895384ab9a83c8b64d47
2 files changed +2 -2
cmd/webclient/httpjs/http_js.go
+1 -1
@@ -256,7 +256,7 @@ func (resp *Response) ReadAll() ([]byte, error) {
256 }
257
258 var buf bytes.Buffer
259 - buffer := make([]byte, 4096)
259 + buffer := make([]byte, 32*1024) // 32KB buffer to reduce Go-JS boundary crossings
260
261 for {
262 n, err := resp.bodyReader.Read(buffer)
cmd/webclient/streamjs/stream_js.go
+1 -1
@@ -30,7 +30,7 @@ func NewReadableStream(r io.ReadCloser) *ReadableStream {
30 // 1. Go 래퍼 구조체를 먼저 생성합니다.
31 rs := &ReadableStream{
32 r: r,
33 - buffer: make([]byte, 4096), // 4KB 버퍼로 초기화
33 + buffer: make([]byte, 32*1024), // 32KB buffer to reduce Go-JS boundary crossings
34 }
35
36 // 2. JS 콜백 함수들을 정의합니다. 이 함수들은 'rs' 포인터를 클로저로 캡처합니다.