Commit b0dda9d2 authored by Kirill Smelkov's avatar Kirill Smelkov

X serveRecv: help Go scheduler to switch to receiving G sooner

LinkNetPipeRTT-4  3.05µs ± 1%  2.99µs ± 0%   -2.05%  (p=0.008 n=5+5)
LinkTCPRTT-4      15.9µs ± 1%  14.3µs ± 2%  -10.11%  (p=0.008 n=5+5)
parent 4989918a
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"math" "math"
"net" "net"
"reflect" "reflect"
"runtime"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
...@@ -687,19 +688,6 @@ func (c *Conn) recvPkt() (*PktBuf, error) { ...@@ -687,19 +688,6 @@ func (c *Conn) recvPkt() (*PktBuf, error) {
return pkt, err return pkt, err
} }
/*
// recvPkt receives raw packet from connection
func (c *Conn) recvPkt() (*PktBuf, error) {
select {
case <-c.rxdown:
return nil, c.err("recv", c.errRecvShutdown())
case pkt := <-c.rxq:
return pkt, nil
}
}
*/
// serveRecv handles incoming packets routing them to either appropriate // serveRecv handles incoming packets routing them to either appropriate
// already-established connection or, if node link is accepting incoming // already-established connection or, if node link is accepting incoming
// connections, to new connection put to accept queue. // connections, to new connection put to accept queue.
...@@ -797,6 +785,13 @@ func (nl *NodeLink) serveRecv() { ...@@ -797,6 +785,13 @@ func (nl *NodeLink) serveRecv() {
} }
//fmt.Printf("%p\tafter accept\n", nl) //fmt.Printf("%p\tafter accept\n", nl)
// Normally serveRecv G will continue to run with G waking up
// on rxq/acceptq only being put into the runqueue of current proc.
// By default proc runq will execute only when sendRecv blocks
// next time deep in nl.recvPkt(), but let's force the switch
// now without additional wating to reduce latency.
runtime.Gosched()
/* /*
// XXX goes away in favour of .rxdownFlag; reasons // XXX goes away in favour of .rxdownFlag; reasons
// - no need to reallocate rxdown for light conn // - no need to reallocate rxdown for light 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