Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use a buffered reader, ReadFromPackedStream() does a lot of reads
…which would directly translate into tons of read() syscalls, which is
pretty expensive.
  • Loading branch information
stapelberg committed Dec 14, 2014
1 parent 818db7c commit 684467a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/dcs-web/querymanager.go
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"encoding/json"
"flag"
"fmt"
Expand Down Expand Up @@ -234,10 +235,12 @@ func queryBackend(queryid string, backend string, backendidx int, sourceQuery []
return
}

bufferedReader := bufio.NewReaderSize(conn, 65536)

for !state[queryid].done {
conn.SetReadDeadline(time.Now().Add(10 * time.Second))

seg, err := capn.ReadFromPackedStream(conn, nil)
seg, err := capn.ReadFromPackedStream(bufferedReader, nil)
if err != nil {
if err == io.EOF {
log.Printf("[%s] [src:%s] EOF\n", queryid, backend)
Expand Down

0 comments on commit 684467a

Please sign in to comment.