Skip to content

use write to serve byte array

bmcculley requested to merge bmcculley/kcup-go:use-bytearray into main

Use write to directly serve byte array.

Some more modest improvements.

Tested with 100K file base64 /dev/urandom | head -c 100K > file.txt

Original code on my machine

wrk -t12 -c400 -d30s --latency http://127.0.0.1:5000
Running 30s test @ http://127.0.0.1:5000
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    33.47ms   18.69ms 271.10ms   72.80%
    Req/Sec     0.98k   236.19     2.28k    75.77%
  Latency Distribution
     50%   34.01ms
     75%   43.87ms
     90%   55.11ms
     99%   85.56ms
  351127 requests in 30.10s, 33.53GB read
Requests/sec:  11665.32
Transfer/sec:      1.11GB

With this patch

wrk -t12 -c400 -d30s --latency http://127.0.0.1:5000
Running 30s test @ http://127.0.0.1:5000
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    30.41ms   16.98ms 174.34ms   71.95%
    Req/Sec     1.07k   252.15     3.05k    75.49%
  Latency Distribution
     50%   30.92ms
     75%   40.19ms
     90%   50.49ms
     99%   76.09ms
  384099 requests in 30.10s, 36.68GB read
Requests/sec:  12761.09
Transfer/sec:      1.22GB

Merge request reports