Skip to content

Commit

Permalink
ccl/sqlproxyccl: add benchmarks for connection copying logic
Browse files Browse the repository at this point in the history
Informs cockroachdb#76000. Follow up to cockroachdb#76006.

This commit adds a benchmark test for the connection copying logic.

```
    go version go1.17.3 linux/amd64
    ---
    goos: linux
    goarch: amd64
    pkg: github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/interceptor
    cpu: AMD Ryzen 9 5950X 16-Core Processor
    BenchmarkConnectionCopy/msgCount=10000/msgLen=170/io.Copy-32                   385      3538410 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=170/io.CopyN-32                  15      75036404 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=170/pgproto3-32                  26      42251150 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=170/chunkreader-32               18      65000047 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=170/interceptor-32               33      39125341 ns/op

    BenchmarkConnectionCopy/msgCount=500/msgLen=320/io.Copy-32                   3204        406888 ns/op
    BenchmarkConnectionCopy/msgCount=500/msgLen=320/io.CopyN-32                   410       3123298 ns/op
    BenchmarkConnectionCopy/msgCount=500/msgLen=320/pgproto3-32                   577       2387535 ns/op
    BenchmarkConnectionCopy/msgCount=500/msgLen=320/chunkreader-32                469       3565173 ns/op
    BenchmarkConnectionCopy/msgCount=500/msgLen=320/interceptor-32                652       2015079 ns/op

    BenchmarkConnectionCopy/msgCount=9000/msgLen=2900/io.Copy-32                   49      23330567 ns/op
    BenchmarkConnectionCopy/msgCount=9000/msgLen=2900/io.CopyN-32                  18      72003323 ns/op
    BenchmarkConnectionCopy/msgCount=9000/msgLen=2900/pgproto3-32                  15      82500818 ns/op
    BenchmarkConnectionCopy/msgCount=9000/msgLen=2900/chunkreader-32               18      79832494 ns/op
    BenchmarkConnectionCopy/msgCount=9000/msgLen=2900/interceptor-32               20      54727023 ns/op

    BenchmarkConnectionCopy/msgCount=5000/msgLen=30000/io.Copy-32                  12      98640876 ns/op
    BenchmarkConnectionCopy/msgCount=5000/msgLen=30000/io.CopyN-32                 10     110690053 ns/op
    BenchmarkConnectionCopy/msgCount=5000/msgLen=30000/pgproto3-32                  6     177894915 ns/op
    BenchmarkConnectionCopy/msgCount=5000/msgLen=30000/chunkreader-32               9     129588686 ns/op
    BenchmarkConnectionCopy/msgCount=5000/msgLen=30000/interceptor-32               9     112610362 ns/op

    BenchmarkConnectionCopy/msgCount=10000/msgLen=10/io.Copy-32                   591       2274817 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=10/io.CopyN-32                   25      47465099 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=10/pgproto3-32                   58      23077900 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=10/chunkreader-32                38      31459201 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=10/interceptor-32                64      17616468 ns/op

    BenchmarkConnectionCopy/msgCount=10000/msgLen=15/io.Copy-32                   531       2336896 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=15/io.CopyN-32                   30      45135200 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=15/pgproto3-32                   51      22100293 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=15/chunkreader-32                49      28931167 ns/op
    BenchmarkConnectionCopy/msgCount=10000/msgLen=15/interceptor-32                66      15189020 ns/op
```

Release note: None
  • Loading branch information
jaylim-crl committed Feb 11, 2022
1 parent a983a19 commit 9b3b323
Show file tree
Hide file tree
Showing 2 changed files with 659 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/ccl/sqlproxyccl/interceptor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ go_library(

go_test(
name = "interceptor_test",
srcs = ["interceptor_test.go"],
srcs = [
"bench_test.go",
"interceptor_test.go",
],
embed = [":interceptor"],
deps = [
"//pkg/sql/pgwire/pgwirebase",
"//pkg/util/grpcutil",
"//pkg/util/leaktest",
"//pkg/util/log",
"//pkg/util/stop",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_logtags//:logtags",
"@com_github_jackc_chunkreader_v2//:chunkreader",
"@com_github_jackc_pgproto3_v2//:pgproto3",
"@com_github_stretchr_testify//require",
],
Expand Down
Loading

0 comments on commit 9b3b323

Please sign in to comment.