Permalink
Browse files

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 684467aef59ac4b3c2488666c54cdd865b254f49
Showing with 4 additions and 1 deletion.
  1. +4 −1 cmd/dcs-web/querymanager.go
@@ -1,6 +1,7 @@
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
@@ -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)

0 comments on commit 684467a

Please sign in to comment.