• Brad Fitzpatrick's avatar
    http2: reduce the number of select cases in serverConn.server · 34057069
    Brad Fitzpatrick authored
    This drops the number of select cases in serverConn.server from 10 to
    6. It was 7 in Go 1.7. It increased to 10 in Go 1.8.
    
    * replace testing-only testHookCh with always-on grab-bag serveMsgCh
      to be used for both test purposes, and infrequently used message
      types
    
    * remove the settingsTimer.C case for the initial settings timer
      and use serveMsgCh and time.AfterFunc instead
    
    * ... and do the same for the idle timeout timer.
    
    * ... and for the shutdown timer.
    
    * remove wantStartPushCh and just send the *startPushRequest to
      serveMsgCh too
    
    I could go further with this (and plan to, later), but these are the
    safe and easy ones that don't require more work elsewhere.
    
    The speed gets better the more the request/response go via the
    serverConn.serve loop. (once per Request.Body.Read or
    ResponseWriter.Flush):
    
      name            old time/op    new time/op  delta
      ServerGets-4    138µs ± 3%     134µs ± 2%   -2.54%   (p=0.002 n=10+10)
      ServerPosts-4   176µs ±27%     154µs ± 2%   -12.62%  (p=0.011 n=10+10)
    
    Updates kubernetes/kubernetes#45216
    Updates golang/go#20302
    
    Change-Id: I18019554089d7e3d76355d7137b5957e9597e803
    Reviewed-on: https://go-review.googlesource.com/43034
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarTom Bergan <tombergan@google.com>
    34057069
server_test.go 102 KB