• Dmitry Vyukov's avatar
    runtime: avoid runtimeNano call on a common netpoll path · 21f7f012
    Dmitry Vyukov authored
    runtimeNano is slower than nanotime, so pass the duration
    to runtime_pollSetDeadline as is. netpoll can add nanotime itself.
    Arguably a bit simpler because, say, a negative duration
    clearly represents already expired timer, no need to compare to
    nanotime again.
    This may also fix an obscure corner case when a deadline in past
    which happens to be nanotime 0 is confused with no deadline at all,
    which are radically different things.
    Also don't compute any durations and times if Time is zero
    (currently we first compute everything and then reset d back to 0,
    which is wasteful).
    
    name                  old time/op  new time/op  delta
    TCP4OneShotTimeout-6  17.1µs ± 0%  17.0µs ± 0%     ~     (p=0.421 n=5+5)
    SetReadDeadline-6      230ns ± 0%   205ns ± 1%  -10.63%  (p=0.008 n=5+5)
    
    Change-Id: I2aad699270289a5b9ead68f5e44ec4ec6d96baa0
    Reviewed-on: https://go-review.googlesource.com/c/146344Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
    21f7f012
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...