Commit 851864a9 authored by Kirill Smelkov's avatar Kirill Smelkov

X chan RTT benchmark which simulates Recv1 = Accept + Recv

if rxq is buffered it adds only ~50ns to SyncChanRTT (was ~ 350ns ->
400ns) and important: no extra goroutines switches are introduced
(verified via analyzing trace).
parent f302d93e
...@@ -753,6 +753,40 @@ func BenchmarkBufChanRTT(b *testing.B) { ...@@ -753,6 +753,40 @@ func BenchmarkBufChanRTT(b *testing.B) {
benchmarkChanRTT(b, make(chan byte, 1), make(chan byte, 1)) benchmarkChanRTT(b, make(chan byte, 1), make(chan byte, 1))
} }
// rtt over (acceptq, rxq) & ack chans - base comparision for link.Accept + conn.Recv
func BenchmarkBufChanAXRXRTT(b *testing.B) {
axq := make(chan chan byte)
ack := make(chan byte)
go func() {
for {
// accept
rxq, ok := <-axq
if !ok {
break
}
// recv
c := <-rxq
// send back
ack <- c
}
}()
rxq := make(chan byte, 1) // buffered
for i := 0; i < b.N; i++ {
c := byte(i)
axq <- rxq
rxq <- c
cc := <-ack
if cc != c {
b.Fatalf("sent %q != got %q", c, cc)
}
}
close(axq)
}
// rtt over net.Conn Read/Write // rtt over net.Conn Read/Write
func benchmarkNetConnRTT(b *testing.B, c1, c2 net.Conn) { func benchmarkNetConnRTT(b *testing.B, c1, c2 net.Conn) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment