Skip to content

Commit 8b325d9

Browse files
committed
Increase file transfer buffer from 512 to 16384 bytes
The 512-byte buffer size results in excessive system calls when serving files. For a 1MB file, this requires 2048 read/write operations. Using 16KB reduces system call overhead by 32x and better matches typical OS page sizes and network buffer defaults. This should improve throughput for static file serving while maintaining reasonable stack usage.
1 parent fe194e6 commit 8b325d9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

llamafile/server/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ Client::dispatcher()
784784
should_send_error_if_canceled_ = false;
785785
if (!send(std::string_view(obuf_.p, p - obuf_.p)))
786786
return false;
787-
char buf[512];
787+
char buf[16384];
788788
size_t i, chunk;
789789
for (i = 0; i < size; i += chunk) {
790790
chunk = size - i;

0 commit comments

Comments
 (0)