Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: consider less allocations for Conn.Read #53142

Open
TriAnMan opened this issue May 30, 2022 · 4 comments
Open

crypto/tls: consider less allocations for Conn.Read #53142

TriAnMan opened this issue May 30, 2022 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@TriAnMan
Copy link

TriAnMan commented May 30, 2022

What version of Go are you using (go version)?

$ go version
go version go1.17.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/anton/Library/Caches/go-build"
GOENV="/Users/anton/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/anton/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/anton/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3_/brw14zgj1sd1x1hnnz4p02tm0000gn/T/go-build266993821=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm running a websocket client application consuming lots of short messages from its established websocket connection.

What did you expect to see?

I would like to have no allocations for Conn.Read calls.

What did you see instead?

Each call of Conn.Read allocates one atLeastReader while going through Conn.readFromUntil.

There also were some redundant allocations fixed in #50657.
Combining #50657 with the patch I'm currently doing makes Conn.Read have zero allocations.

@TriAnMan
Copy link
Author

TriAnMan commented May 30, 2022

The bechmarks of #53143 against release-branch.go1.17 show considerable improvement in performance:

1.17 bench
name                                     old time/op    new time/op    delta
Throughput/MaxPacket/1MB/TLSv12-12         3.93ms ± 3%    3.95ms ± 4%     ~     (p=0.305 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12         4.18ms ± 2%    4.20ms ± 2%     ~     (p=0.375 n=13+14)
Throughput/MaxPacket/2MB/TLSv12-12         7.23ms ± 3%    7.15ms ± 3%   -1.18%  (p=0.037 n=13+15)
Throughput/MaxPacket/2MB/TLSv13-12         7.43ms ± 6%    7.16ms ± 2%   -3.54%  (p=0.000 n=14+15)
Throughput/MaxPacket/4MB/TLSv12-12         13.7ms ± 7%    12.9ms ± 1%   -5.85%  (p=0.000 n=15+12)
Throughput/MaxPacket/4MB/TLSv13-12         14.3ms ± 8%    13.1ms ± 1%   -8.58%  (p=0.000 n=15+13)
Throughput/MaxPacket/8MB/TLSv12-12         25.2ms ± 2%    24.6ms ± 1%   -2.63%  (p=0.000 n=14+14)
Throughput/MaxPacket/8MB/TLSv13-12         26.1ms ± 3%    25.0ms ± 1%   -4.20%  (p=0.000 n=14+14)
Throughput/MaxPacket/16MB/TLSv12-12        51.3ms ± 5%    47.5ms ± 1%   -7.52%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv13-12        53.0ms ± 7%    48.7ms ± 1%   -8.10%  (p=0.000 n=14+14)
Throughput/MaxPacket/32MB/TLSv12-12        99.0ms ± 3%    94.7ms ± 0%   -4.40%  (p=0.000 n=14+13)
Throughput/MaxPacket/32MB/TLSv13-12         100ms ± 3%      96ms ± 1%   -4.09%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12         194ms ± 4%     187ms ± 1%   -3.76%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv13-12         200ms ± 3%     191ms ± 1%   -4.33%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12     4.07ms ± 7%    3.93ms ± 3%   -3.59%  (p=0.000 n=14+15)
Throughput/DynamicPacket/1MB/TLSv13-12     4.37ms ± 5%    4.23ms ± 4%   -3.21%  (p=0.008 n=15+15)
Throughput/DynamicPacket/2MB/TLSv12-12     8.86ms ±56%    7.26ms ± 3%  -18.02%  (p=0.000 n=15+15)
Throughput/DynamicPacket/2MB/TLSv13-12     7.45ms ± 4%    7.21ms ± 1%   -3.23%  (p=0.000 n=12+15)
Throughput/DynamicPacket/4MB/TLSv12-12     13.5ms ± 2%    13.0ms ± 1%   -3.65%  (p=0.000 n=14+15)
Throughput/DynamicPacket/4MB/TLSv13-12     14.0ms ±13%    13.2ms ± 1%   -5.76%  (p=0.000 n=13+15)
Throughput/DynamicPacket/8MB/TLSv12-12     25.0ms ± 1%    24.6ms ± 1%   -1.57%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv13-12     25.9ms ± 3%    25.0ms ± 1%   -3.23%  (p=0.000 n=13+15)
Throughput/DynamicPacket/16MB/TLSv12-12    49.8ms ± 3%    48.1ms ± 1%   -3.43%  (p=0.000 n=14+15)
Throughput/DynamicPacket/16MB/TLSv13-12    49.5ms ± 1%    48.8ms ± 0%   -1.31%  (p=0.000 n=14+15)
Throughput/DynamicPacket/32MB/TLSv12-12     101ms ±11%      95ms ± 1%   -6.15%  (p=0.000 n=15+14)
Throughput/DynamicPacket/32MB/TLSv13-12     112ms ±23%      96ms ± 1%  -13.70%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12     196ms ± 3%     189ms ± 1%   -3.66%  (p=0.000 n=12+15)
Throughput/DynamicPacket/64MB/TLSv13-12     194ms ± 1%     192ms ± 1%   -1.28%  (p=0.000 n=15+15)
name                                     old speed      new speed      delta
Throughput/MaxPacket/1MB/TLSv12-12        267MB/s ± 3%   266MB/s ± 3%     ~     (p=0.305 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12        251MB/s ± 2%   250MB/s ± 2%     ~     (p=0.375 n=13+14)
Throughput/MaxPacket/2MB/TLSv12-12        290MB/s ± 3%   294MB/s ± 3%   +1.20%  (p=0.037 n=13+15)
Throughput/MaxPacket/2MB/TLSv13-12        283MB/s ± 6%   293MB/s ± 2%   +3.60%  (p=0.000 n=14+15)
Throughput/MaxPacket/4MB/TLSv12-12        307MB/s ± 7%   325MB/s ± 1%   +6.10%  (p=0.000 n=15+12)
Throughput/MaxPacket/4MB/TLSv13-12        294MB/s ± 8%   321MB/s ± 1%   +9.14%  (p=0.000 n=15+14)
Throughput/MaxPacket/8MB/TLSv12-12        333MB/s ± 2%   341MB/s ± 1%   +2.69%  (p=0.000 n=14+14)
Throughput/MaxPacket/8MB/TLSv13-12        320MB/s ± 5%   335MB/s ± 1%   +4.75%  (p=0.000 n=15+14)
Throughput/MaxPacket/16MB/TLSv12-12       327MB/s ± 5%   353MB/s ± 1%   +8.07%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv13-12       317MB/s ± 7%   345MB/s ± 1%   +8.72%  (p=0.000 n=14+14)
Throughput/MaxPacket/32MB/TLSv12-12       339MB/s ± 3%   354MB/s ± 0%   +4.59%  (p=0.000 n=14+13)
Throughput/MaxPacket/32MB/TLSv13-12       335MB/s ± 3%   349MB/s ± 1%   +4.26%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12       346MB/s ± 4%   359MB/s ± 1%   +3.87%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv13-12       336MB/s ± 3%   351MB/s ± 1%   +4.49%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12    258MB/s ± 6%   267MB/s ± 3%   +3.68%  (p=0.000 n=14+15)
Throughput/DynamicPacket/1MB/TLSv13-12    240MB/s ± 6%   248MB/s ± 4%   +3.30%  (p=0.008 n=15+15)
Throughput/DynamicPacket/2MB/TLSv12-12    248MB/s ±39%   289MB/s ± 3%  +16.31%  (p=0.000 n=15+15)
Throughput/DynamicPacket/2MB/TLSv13-12    282MB/s ± 4%   291MB/s ± 1%   +3.28%  (p=0.000 n=12+15)
Throughput/DynamicPacket/4MB/TLSv12-12    311MB/s ± 2%   322MB/s ± 1%   +3.77%  (p=0.000 n=14+15)
Throughput/DynamicPacket/4MB/TLSv13-12    301MB/s ±11%   319MB/s ± 1%   +5.89%  (p=0.000 n=13+15)
Throughput/DynamicPacket/8MB/TLSv12-12    335MB/s ± 1%   340MB/s ± 1%   +1.60%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv13-12    324MB/s ± 3%   335MB/s ± 1%   +3.32%  (p=0.000 n=13+15)
Throughput/DynamicPacket/16MB/TLSv12-12   337MB/s ± 3%   349MB/s ± 1%   +3.54%  (p=0.000 n=14+15)
Throughput/DynamicPacket/16MB/TLSv13-12   339MB/s ± 1%   344MB/s ± 0%   +1.32%  (p=0.000 n=14+15)
Throughput/DynamicPacket/32MB/TLSv12-12   332MB/s ±10%   353MB/s ± 1%   +6.31%  (p=0.000 n=15+14)
Throughput/DynamicPacket/32MB/TLSv13-12   304MB/s ±20%   348MB/s ± 1%  +14.58%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12   343MB/s ± 3%   356MB/s ± 1%   +3.78%  (p=0.000 n=12+15)
Throughput/DynamicPacket/64MB/TLSv13-12   345MB/s ± 1%   350MB/s ± 1%   +1.29%  (p=0.000 n=15+15)
name                                     old alloc/op   new alloc/op   delta
Throughput/MaxPacket/1MB/TLSv12-12          213kB ± 1%     210kB ± 1%   -1.38%  (p=0.000 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12          251kB ± 0%     248kB ± 0%   -1.16%  (p=0.000 n=14+15)
Throughput/MaxPacket/2MB/TLSv12-12          216kB ± 1%     211kB ± 1%   -2.28%  (p=0.000 n=15+15)
Throughput/MaxPacket/2MB/TLSv13-12          254kB ± 1%     249kB ± 1%   -2.17%  (p=0.000 n=15+14)
Throughput/MaxPacket/4MB/TLSv12-12          220kB ± 1%     211kB ± 0%   -4.18%  (p=0.000 n=15+14)
Throughput/MaxPacket/4MB/TLSv13-12          259kB ± 1%     249kB ± 1%   -3.86%  (p=0.000 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12          228kB ± 1%     213kB ± 1%   -6.62%  (p=0.000 n=12+14)
Throughput/MaxPacket/8MB/TLSv13-12          267kB ± 1%     251kB ± 1%   -5.66%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv12-12         244kB ± 2%     215kB ± 3%  -11.78%  (p=0.000 n=14+15)
Throughput/MaxPacket/16MB/TLSv13-12         282kB ± 2%     252kB ± 2%  -10.45%  (p=0.000 n=15+15)
Throughput/MaxPacket/32MB/TLSv12-12         274kB ± 3%     216kB ± 1%  -21.26%  (p=0.000 n=15+14)
Throughput/MaxPacket/32MB/TLSv13-12         313kB ± 3%     255kB ± 3%  -18.57%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12         338kB ± 6%     218kB ± 1%  -35.62%  (p=0.000 n=15+13)
Throughput/MaxPacket/64MB/TLSv13-12         377kB ± 5%     261kB ± 6%  -30.68%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12      261kB ± 1%     255kB ± 2%   -2.23%  (p=0.000 n=13+15)
Throughput/DynamicPacket/1MB/TLSv13-12      294kB ± 1%     289kB ± 1%   -1.48%  (p=0.000 n=15+15)
Throughput/DynamicPacket/2MB/TLSv12-12      262kB ± 4%     255kB ± 2%   -2.70%  (p=0.000 n=14+14)
Throughput/DynamicPacket/2MB/TLSv13-12      296kB ± 1%     289kB ± 2%   -2.44%  (p=0.000 n=15+15)
Throughput/DynamicPacket/4MB/TLSv12-12      266kB ± 4%     257kB ± 4%   -3.38%  (p=0.000 n=15+14)
Throughput/DynamicPacket/4MB/TLSv13-12      300kB ± 1%     290kB ± 3%   -3.36%  (p=0.000 n=14+15)
Throughput/DynamicPacket/8MB/TLSv12-12      276kB ± 5%     256kB ± 3%   -7.34%  (p=0.000 n=14+15)
Throughput/DynamicPacket/8MB/TLSv13-12      303kB ± 2%     290kB ± 3%   -4.53%  (p=0.000 n=15+15)
Throughput/DynamicPacket/16MB/TLSv12-12     289kB ± 5%     255kB ± 4%  -11.68%  (p=0.000 n=15+15)
Throughput/DynamicPacket/16MB/TLSv13-12     320kB ± 5%     288kB ± 3%   -9.87%  (p=0.000 n=14+15)
Throughput/DynamicPacket/32MB/TLSv12-12     318kB ± 4%     257kB ±12%  -19.09%  (p=0.000 n=15+15)
Throughput/DynamicPacket/32MB/TLSv13-12     350kB ± 4%     290kB ± 4%  -17.22%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12     378kB ± 6%     265kB ±14%  -29.83%  (p=0.000 n=14+15)
Throughput/DynamicPacket/64MB/TLSv13-12     414kB ± 2%     305kB ± 9%  -26.26%  (p=0.000 n=13+15)
name                                     old allocs/op  new allocs/op  delta
Throughput/MaxPacket/1MB/TLSv12-12            586 ± 0%       507 ± 0%  -13.50%  (p=0.000 n=15+12)
Throughput/MaxPacket/1MB/TLSv13-12          1.22k ± 0%     1.14k ± 0%   -6.29%  (p=0.000 n=13+14)
Throughput/MaxPacket/2MB/TLSv12-12            657 ± 0%       507 ± 0%  -22.88%  (p=0.000 n=13+15)
Throughput/MaxPacket/2MB/TLSv13-12          1.29k ± 0%     1.14k ± 0%  -11.35%  (p=0.000 n=14+13)
Throughput/MaxPacket/4MB/TLSv12-12            803 ± 1%       507 ± 0%  -36.84%  (p=0.000 n=15+14)
Throughput/MaxPacket/4MB/TLSv13-12          1.43k ± 1%     1.14k ± 0%  -20.21%  (p=0.000 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12          1.08k ± 1%     0.51k ± 0%  -53.14%  (p=0.000 n=13+15)
Throughput/MaxPacket/8MB/TLSv13-12          1.71k ± 1%     1.14k ± 0%  -33.17%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv12-12         1.67k ± 1%     0.51k ± 0%  -69.56%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv13-12         2.29k ± 1%     1.14k ± 0%  -50.00%  (p=0.000 n=14+15)
Throughput/MaxPacket/32MB/TLSv12-12         2.80k ± 2%     0.51k ± 0%  -81.86%  (p=0.000 n=14+15)
Throughput/MaxPacket/32MB/TLSv13-12         3.37k ± 1%     1.14k ± 0%  -66.07%  (p=0.000 n=14+15)
Throughput/MaxPacket/64MB/TLSv12-12         5.04k ± 3%     0.51k ± 0%  -89.89%  (p=0.000 n=15+14)
Throughput/MaxPacket/64MB/TLSv13-12         5.59k ± 1%     1.15k ± 0%  -79.48%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12        601 ± 0%       514 ± 0%  -14.57%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv13-12      1.24k ± 0%     1.15k ± 0%   -6.94%  (p=0.000 n=14+15)
Throughput/DynamicPacket/2MB/TLSv12-12        678 ± 3%       514 ± 0%  -24.18%  (p=0.000 n=14+14)
Throughput/DynamicPacket/2MB/TLSv13-12      1.30k ± 0%     1.15k ± 0%  -11.86%  (p=0.000 n=13+15)
Throughput/DynamicPacket/4MB/TLSv12-12        813 ± 1%       514 ± 0%  -36.76%  (p=0.000 n=13+15)
Throughput/DynamicPacket/4MB/TLSv13-12      1.45k ± 1%     1.15k ± 0%  -20.44%  (p=0.000 n=13+15)
Throughput/DynamicPacket/8MB/TLSv12-12      1.10k ± 1%     0.51k ± 0%  -53.16%  (p=0.000 n=14+15)
Throughput/DynamicPacket/8MB/TLSv13-12      1.72k ± 1%     1.15k ± 0%  -33.33%  (p=0.000 n=14+14)
Throughput/DynamicPacket/16MB/TLSv12-12     1.67k ± 2%     0.51k ± 0%  -69.27%  (p=0.000 n=15+15)
Throughput/DynamicPacket/16MB/TLSv13-12     2.26k ± 1%     1.15k ± 0%  -49.20%  (p=0.000 n=15+14)
Throughput/DynamicPacket/32MB/TLSv12-12     2.83k ± 3%     0.51k ± 0%  -81.85%  (p=0.000 n=15+13)
Throughput/DynamicPacket/32MB/TLSv13-12     3.49k ± 6%     1.15k ± 0%  -67.05%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12     5.12k ± 3%     0.52k ± 1%  -89.90%  (p=0.000 n=14+15)
Throughput/DynamicPacket/64MB/TLSv13-12     5.58k ± 1%     1.15k ± 1%  -79.30%  (p=0.000 n=14+15)

Benchmarking against release-branch.go1.18 shows less but consistent improvement:

1.18 bench
name                                     old time/op    new time/op    delta
Throughput/MaxPacket/1MB/TLSv12-12         3.90ms ± 4%    3.92ms ±12%     ~     (p=0.595 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12         4.14ms ± 5%    4.09ms ± 3%     ~     (p=0.118 n=15+13)
Throughput/MaxPacket/2MB/TLSv12-12         7.00ms ± 3%    6.92ms ± 2%   -1.25%  (p=0.008 n=15+14)
Throughput/MaxPacket/2MB/TLSv13-12         7.05ms ± 3%    6.99ms ± 2%   -0.76%  (p=0.041 n=15+14)
Throughput/MaxPacket/4MB/TLSv12-12         12.7ms ± 1%    12.6ms ± 1%     ~     (p=0.274 n=13+15)
Throughput/MaxPacket/4MB/TLSv13-12         12.9ms ± 1%    12.9ms ± 1%     ~     (p=0.744 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12         24.2ms ± 1%    24.0ms ± 1%   -0.49%  (p=0.033 n=15+15)
Throughput/MaxPacket/8MB/TLSv13-12         24.7ms ± 1%    24.5ms ± 1%   -0.79%  (p=0.000 n=15+14)
Throughput/MaxPacket/16MB/TLSv12-12        47.3ms ± 1%    47.2ms ± 3%     ~     (p=0.201 n=14+15)
Throughput/MaxPacket/16MB/TLSv13-12        48.2ms ± 1%    47.9ms ± 1%     ~     (p=0.063 n=15+14)
Throughput/MaxPacket/32MB/TLSv12-12        93.9ms ± 1%    92.3ms ± 0%   -1.74%  (p=0.000 n=14+15)
Throughput/MaxPacket/32MB/TLSv13-12        95.0ms ± 1%    94.3ms ± 1%   -0.80%  (p=0.001 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12         185ms ± 1%     183ms ± 1%   -1.06%  (p=0.000 n=14+13)
Throughput/MaxPacket/64MB/TLSv13-12         189ms ± 1%     188ms ± 3%     ~     (p=0.201 n=14+15)
Throughput/DynamicPacket/1MB/TLSv12-12     3.81ms ± 2%    3.79ms ± 2%   -0.62%  (p=0.046 n=14+15)
Throughput/DynamicPacket/1MB/TLSv13-12     4.13ms ± 4%    4.08ms ± 5%     ~     (p=0.112 n=15+14)
Throughput/DynamicPacket/2MB/TLSv12-12     7.10ms ± 3%    6.98ms ± 4%   -1.73%  (p=0.006 n=15+14)
Throughput/DynamicPacket/2MB/TLSv13-12     7.04ms ± 2%    7.03ms ± 1%     ~     (p=0.847 n=14+15)
Throughput/DynamicPacket/4MB/TLSv12-12     12.8ms ± 2%    12.6ms ± 1%   -1.16%  (p=0.000 n=15+14)
Throughput/DynamicPacket/4MB/TLSv13-12     12.9ms ± 1%    12.8ms ± 1%   -0.89%  (p=0.000 n=14+15)
Throughput/DynamicPacket/8MB/TLSv12-12     24.2ms ± 1%    24.1ms ± 1%   -0.67%  (p=0.005 n=14+14)
Throughput/DynamicPacket/8MB/TLSv13-12     24.6ms ± 1%    24.4ms ± 1%   -0.84%  (p=0.000 n=14+14)
Throughput/DynamicPacket/16MB/TLSv12-12    47.3ms ± 1%    46.9ms ± 1%   -0.78%  (p=0.000 n=13+15)
Throughput/DynamicPacket/16MB/TLSv13-12    48.2ms ± 1%    47.9ms ± 2%   -0.65%  (p=0.023 n=15+14)
Throughput/DynamicPacket/32MB/TLSv12-12    93.5ms ± 1%    92.6ms ± 1%   -0.90%  (p=0.000 n=15+13)
Throughput/DynamicPacket/32MB/TLSv13-12    94.7ms ± 1%    94.7ms ± 1%     ~     (p=0.769 n=14+14)
Throughput/DynamicPacket/64MB/TLSv12-12     186ms ± 2%     185ms ± 1%   -0.75%  (p=0.008 n=15+14)
Throughput/DynamicPacket/64MB/TLSv13-12     189ms ± 1%     188ms ± 1%   -0.72%  (p=0.000 n=13+15)
name                                     old speed      new speed      delta
Throughput/MaxPacket/1MB/TLSv12-12        269MB/s ± 4%   268MB/s ±11%     ~     (p=0.595 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12        253MB/s ± 4%   256MB/s ± 3%     ~     (p=0.118 n=15+13)
Throughput/MaxPacket/2MB/TLSv12-12        300MB/s ± 3%   303MB/s ± 2%   +1.26%  (p=0.008 n=15+14)
Throughput/MaxPacket/2MB/TLSv13-12        298MB/s ± 3%   300MB/s ± 2%   +0.76%  (p=0.041 n=15+14)
Throughput/MaxPacket/4MB/TLSv12-12        331MB/s ± 1%   332MB/s ± 1%     ~     (p=0.279 n=13+15)
Throughput/MaxPacket/4MB/TLSv13-12        325MB/s ± 1%   325MB/s ± 1%     ~     (p=0.736 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12        347MB/s ± 1%   349MB/s ± 1%   +0.49%  (p=0.034 n=15+15)
Throughput/MaxPacket/8MB/TLSv13-12        340MB/s ± 1%   343MB/s ± 1%   +0.79%  (p=0.000 n=15+14)
Throughput/MaxPacket/16MB/TLSv12-12       354MB/s ± 1%   356MB/s ± 2%     ~     (p=0.197 n=14+15)
Throughput/MaxPacket/16MB/TLSv13-12       348MB/s ± 1%   350MB/s ± 1%     ~     (p=0.063 n=15+14)
Throughput/MaxPacket/32MB/TLSv12-12       357MB/s ± 1%   364MB/s ± 0%   +1.77%  (p=0.000 n=14+15)
Throughput/MaxPacket/32MB/TLSv13-12       353MB/s ± 1%   356MB/s ± 1%   +0.81%  (p=0.001 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12       363MB/s ± 1%   367MB/s ± 1%   +1.07%  (p=0.000 n=14+13)
Throughput/MaxPacket/64MB/TLSv13-12       355MB/s ± 1%   356MB/s ± 3%     ~     (p=0.201 n=14+15)
Throughput/DynamicPacket/1MB/TLSv12-12    275MB/s ± 2%   277MB/s ± 2%   +0.63%  (p=0.045 n=14+15)
Throughput/DynamicPacket/1MB/TLSv13-12    254MB/s ± 4%   257MB/s ± 4%     ~     (p=0.109 n=15+14)
Throughput/DynamicPacket/2MB/TLSv12-12    295MB/s ± 3%   300MB/s ± 4%   +1.75%  (p=0.006 n=15+14)
Throughput/DynamicPacket/2MB/TLSv13-12    298MB/s ± 2%   298MB/s ± 1%     ~     (p=0.821 n=14+15)
Throughput/DynamicPacket/4MB/TLSv12-12    328MB/s ± 2%   332MB/s ± 1%   +1.17%  (p=0.000 n=15+14)
Throughput/DynamicPacket/4MB/TLSv13-12    324MB/s ± 1%   327MB/s ± 1%   +0.90%  (p=0.000 n=14+15)
Throughput/DynamicPacket/8MB/TLSv12-12    346MB/s ± 1%   348MB/s ± 1%   +0.68%  (p=0.005 n=14+14)
Throughput/DynamicPacket/8MB/TLSv13-12    341MB/s ± 1%   344MB/s ± 1%   +0.85%  (p=0.000 n=14+14)
Throughput/DynamicPacket/16MB/TLSv12-12   355MB/s ± 1%   357MB/s ± 1%   +0.78%  (p=0.000 n=13+15)
Throughput/DynamicPacket/16MB/TLSv13-12   348MB/s ± 1%   350MB/s ± 2%   +0.67%  (p=0.023 n=15+14)
Throughput/DynamicPacket/32MB/TLSv12-12   359MB/s ± 1%   362MB/s ± 1%   +0.91%  (p=0.000 n=15+13)
Throughput/DynamicPacket/32MB/TLSv13-12   354MB/s ± 1%   354MB/s ± 1%     ~     (p=0.778 n=14+14)
Throughput/DynamicPacket/64MB/TLSv12-12   361MB/s ± 2%   364MB/s ± 1%   +0.75%  (p=0.008 n=15+14)
Throughput/DynamicPacket/64MB/TLSv13-12   354MB/s ± 1%   357MB/s ± 1%   +0.73%  (p=0.000 n=13+15)
name                                     old alloc/op   new alloc/op   delta
Throughput/MaxPacket/1MB/TLSv12-12          208kB ± 0%     205kB ± 0%   -1.09%  (p=0.000 n=15+15)
Throughput/MaxPacket/1MB/TLSv13-12          245kB ± 0%     243kB ± 0%   -0.85%  (p=0.000 n=15+15)
Throughput/MaxPacket/2MB/TLSv12-12          210kB ± 0%     206kB ± 0%   -2.03%  (p=0.000 n=15+15)
Throughput/MaxPacket/2MB/TLSv13-12          247kB ± 0%     243kB ± 0%   -1.68%  (p=0.000 n=15+15)
Throughput/MaxPacket/4MB/TLSv12-12          215kB ± 1%     206kB ± 1%   -4.17%  (p=0.000 n=15+15)
Throughput/MaxPacket/4MB/TLSv13-12          251kB ± 1%     244kB ± 0%   -2.98%  (p=0.000 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12          223kB ± 1%     207kB ± 1%   -7.14%  (p=0.000 n=15+15)
Throughput/MaxPacket/8MB/TLSv13-12          260kB ± 1%     245kB ± 1%   -5.95%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv12-12         241kB ± 2%     208kB ± 1%  -13.86%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv13-12         277kB ± 1%     246kB ± 1%  -11.12%  (p=0.000 n=15+15)
Throughput/MaxPacket/32MB/TLSv12-12         276kB ± 2%     213kB ± 3%  -22.86%  (p=0.000 n=15+15)
Throughput/MaxPacket/32MB/TLSv13-12         312kB ± 2%     250kB ± 2%  -20.12%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12         343kB ± 2%     219kB ± 2%  -36.11%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv13-12         377kB ± 2%     256kB ± 2%  -32.15%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12      244kB ± 1%     242kB ± 2%   -0.76%  (p=0.016 n=14+15)
Throughput/DynamicPacket/1MB/TLSv13-12      280kB ± 1%     277kB ± 1%   -1.06%  (p=0.000 n=15+15)
Throughput/DynamicPacket/2MB/TLSv12-12      247kB ± 2%     242kB ± 1%   -1.91%  (p=0.000 n=15+15)
Throughput/DynamicPacket/2MB/TLSv13-12      282kB ± 1%     278kB ± 1%   -1.45%  (p=0.000 n=15+15)
Throughput/DynamicPacket/4MB/TLSv12-12      251kB ± 2%     241kB ± 2%   -3.98%  (p=0.000 n=15+15)
Throughput/DynamicPacket/4MB/TLSv13-12      287kB ± 1%     278kB ± 1%   -3.17%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv12-12      260kB ± 3%     243kB ± 2%   -6.28%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv13-12      294kB ± 2%     279kB ± 1%   -5.22%  (p=0.000 n=15+14)
Throughput/DynamicPacket/16MB/TLSv12-12     276kB ± 4%     245kB ± 4%  -11.18%  (p=0.000 n=15+15)
Throughput/DynamicPacket/16MB/TLSv13-12     310kB ± 3%     280kB ± 1%   -9.94%  (p=0.000 n=15+15)
Throughput/DynamicPacket/32MB/TLSv12-12     309kB ± 4%     250kB ± 5%  -19.06%  (p=0.000 n=15+14)
Throughput/DynamicPacket/32MB/TLSv13-12     345kB ± 3%     283kB ± 3%  -18.10%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12     385kB ± 6%     247kB ± 8%  -35.86%  (p=0.000 n=15+13)
Throughput/DynamicPacket/64MB/TLSv13-12     414kB ± 5%     290kB ± 4%  -30.04%  (p=0.000 n=15+15)
name                                     old allocs/op  new allocs/op  delta
Throughput/MaxPacket/1MB/TLSv12-12            591 ± 1%       505 ± 0%  -14.57%  (p=0.000 n=15+13)
Throughput/MaxPacket/1MB/TLSv13-12          1.22k ± 0%     1.14k ± 0%   -6.59%  (p=0.000 n=15+15)
Throughput/MaxPacket/2MB/TLSv12-12            670 ± 0%       505 ± 0%  -24.66%  (p=0.000 n=15+13)
Throughput/MaxPacket/2MB/TLSv13-12          1.30k ± 0%     1.14k ± 0%  -11.97%  (p=0.000 n=15+13)
Throughput/MaxPacket/4MB/TLSv12-12            829 ± 1%       505 ± 0%  -39.06%  (p=0.000 n=15+15)
Throughput/MaxPacket/4MB/TLSv13-12          1.45k ± 0%     1.14k ± 0%  -21.27%  (p=0.000 n=15+15)
Throughput/MaxPacket/8MB/TLSv12-12          1.15k ± 1%     0.51k ± 0%  -56.01%  (p=0.000 n=15+13)
Throughput/MaxPacket/8MB/TLSv13-12          1.77k ± 1%     1.14k ± 0%  -35.44%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv12-12         1.80k ± 2%     0.51k ± 0%  -71.88%  (p=0.000 n=15+15)
Throughput/MaxPacket/16MB/TLSv13-12         2.39k ± 1%     1.14k ± 0%  -52.32%  (p=0.000 n=15+15)
Throughput/MaxPacket/32MB/TLSv12-12         3.10k ± 1%     0.51k ± 0%  -83.65%  (p=0.000 n=15+15)
Throughput/MaxPacket/32MB/TLSv13-12         3.67k ± 2%     1.14k ± 0%  -68.84%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv12-12         5.64k ± 3%     0.51k ± 0%  -90.98%  (p=0.000 n=15+15)
Throughput/MaxPacket/64MB/TLSv13-12         6.12k ± 3%     1.14k ± 0%  -81.29%  (p=0.000 n=15+15)
Throughput/DynamicPacket/1MB/TLSv12-12        602 ± 0%       510 ± 0%  -15.23%  (p=0.000 n=15+13)
Throughput/DynamicPacket/1MB/TLSv13-12      1.23k ± 0%     1.15k ± 0%   -7.13%  (p=0.000 n=12+15)
Throughput/DynamicPacket/2MB/TLSv12-12        680 ± 0%       510 ± 0%  -24.96%  (p=0.000 n=15+14)
Throughput/DynamicPacket/2MB/TLSv13-12      1.31k ± 0%     1.15k ± 0%  -12.56%  (p=0.000 n=13+12)
Throughput/DynamicPacket/4MB/TLSv12-12        835 ± 1%       510 ± 0%  -38.95%  (p=0.000 n=15+11)
Throughput/DynamicPacket/4MB/TLSv13-12      1.46k ± 0%     1.15k ± 0%  -21.73%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv12-12      1.16k ± 1%     0.51k ± 0%  -56.00%  (p=0.000 n=15+15)
Throughput/DynamicPacket/8MB/TLSv13-12      1.78k ± 1%     1.15k ± 0%  -35.63%  (p=0.000 n=14+15)
Throughput/DynamicPacket/16MB/TLSv12-12     1.81k ± 2%     0.51k ± 0%  -71.72%  (p=0.000 n=15+15)
Throughput/DynamicPacket/16MB/TLSv13-12     2.40k ± 1%     1.15k ± 0%  -52.18%  (p=0.000 n=14+11)
Throughput/DynamicPacket/32MB/TLSv12-12     3.07k ± 2%     0.51k ± 1%  -83.30%  (p=0.000 n=15+14)
Throughput/DynamicPacket/32MB/TLSv13-12     3.67k ± 2%     1.15k ± 0%  -68.70%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv12-12     5.68k ± 3%     0.51k ± 1%  -90.96%  (p=0.000 n=15+15)
Throughput/DynamicPacket/64MB/TLSv13-12     6.17k ± 3%     1.15k ± 0%  -81.38%  (p=0.000 n=15+15)

Note that allocs per operation became constant for each kind of a test.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/409334 mentions this issue: crypto/tls: reduce the number of allocations made for Conn.Read calls

@dmitshur
Copy link
Contributor

dmitshur commented Jun 1, 2022

CC @golang/security.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 1, 2022
@dmitshur dmitshur added this to the Backlog milestone Jun 1, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/464835 mentions this issue: crypto/tls: store value atLeastReader in tls.Conn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

3 participants