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

perf: reuse requests to reduce allocs #127

Merged
merged 1 commit into from
May 14, 2023
Merged

perf: reuse requests to reduce allocs #127

merged 1 commit into from
May 14, 2023

Conversation

abemedia
Copy link
Owner

@abemedia abemedia commented May 14, 2023

No description provided.

@codecov
Copy link

codecov bot commented May 14, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.18 🎉

Comparison is base (415f4f1) 96.02% compared to head (3606d27) 96.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   96.02%   96.21%   +0.18%     
==========================================
  Files          22       23       +1     
  Lines         806      845      +39     
==========================================
+ Hits          774      813      +39     
  Misses         22       22              
  Partials       10       10              
Impacted Files Coverage Δ
decoder/compile.go 99.40% <100.00%> (-0.01%) ⬇️
decoder/decode.go 100.00% <100.00%> (ø)
encoding/protobuf/protobuf.go 100.00% <100.00%> (ø)
handler.go 96.72% <100.00%> (ø)
pool.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

github-actions bot commented May 14, 2023

Benchmark Result

Benchmark diff with base branch
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don
cpu: Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
                         │ bench-master.txt │            bench-new.txt            │
                         │      sec/op      │   sec/op     vs base                │
Handler/Request-2               540.3n ± 5%   412.6n ± 5%  -23.64% (p=0.000 n=10)
Handler/RequestPointer-2        535.4n ± 4%   451.1n ± 5%  -15.73% (p=0.000 n=10)
geomean                         537.8n        431.4n       -19.78%

                         │ bench-master.txt │           bench-new.txt            │
                         │       B/op       │    B/op     vs base                │
Handler/Request-2                72.00 ± 0%   24.00 ± 0%  -66.67% (p=0.000 n=10)
Handler/RequestPointer-2         80.00 ± 0%   24.00 ± 0%  -70.00% (p=0.000 n=10)
geomean                          75.89        24.00       -68.38%

                         │ bench-master.txt │           bench-new.txt            │
                         │    allocs/op     │ allocs/op   vs base                │
Handler/Request-2                2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
Handler/RequestPointer-2         3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)
geomean                          2.449        1.000       -59.18%

pkg: github.com/abemedia/go-don/encoding/json
              │ bench-master.txt │            bench-new.txt            │
              │      sec/op      │   sec/op     vs base                │
JSON/Decode-2        203.6n ± 3%   139.4n ± 4%  -31.52% (p=0.000 n=10)
JSON/Encode-2        228.3n ± 6%   226.0n ± 4%        ~ (p=0.190 n=10)
geomean              215.6n        177.5n       -17.66%

              │ bench-master.txt │            bench-new.txt             │
              │       B/op       │    B/op     vs base                  │
JSON/Decode-2         32.00 ± 0%   16.00 ± 0%  -50.00% (p=0.000 n=10)
JSON/Encode-2         32.00 ± 0%   32.00 ± 0%        ~ (p=1.000 n=10) ¹
geomean               32.00        22.63       -29.29%
¹ all samples are equal

              │ bench-master.txt │            bench-new.txt             │
              │    allocs/op     │ allocs/op   vs base                  │
JSON/Decode-2         2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
JSON/Encode-2         2.000 ± 0%   2.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean               2.000        1.414       -29.29%
¹ all samples are equal

pkg: github.com/abemedia/go-don/encoding/msgpack
                 │ bench-master.txt │            bench-new.txt            │
                 │      sec/op      │   sec/op     vs base                │
Msgpack/Decode-2        549.0n ± 5%   480.3n ± 3%  -12.51% (p=0.000 n=10)
Msgpack/Encode-2        481.0n ± 3%   458.9n ± 4%   -4.60% (p=0.001 n=10)
geomean                 513.9n        469.5n        -8.64%

                 │ bench-master.txt │            bench-new.txt             │
                 │       B/op       │    B/op     vs base                  │
Msgpack/Decode-2         67.00 ± 0%   51.00 ± 0%  -23.88% (p=0.000 n=10)
Msgpack/Encode-2         128.0 ± 0%   128.0 ± 0%        ~ (p=1.000 n=10) ¹
geomean                  92.61        80.80       -12.75%
¹ all samples are equal

                 │ bench-master.txt │            bench-new.txt             │
                 │    allocs/op     │ allocs/op   vs base                  │
Msgpack/Decode-2         3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
Msgpack/Encode-2         3.000 ± 0%   3.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                  3.000        2.449       -18.35%
¹ all samples are equal

pkg: github.com/abemedia/go-don/encoding/protobuf
                  │ bench-master.txt │            bench-new.txt            │
                  │      sec/op      │   sec/op     vs base                │
Protobuf/Decode-2        509.7n ± 5%   330.6n ± 5%  -35.15% (p=0.000 n=10)
Protobuf/Encode-2        154.9n ± 5%   162.5n ± 4%   +4.87% (p=0.009 n=10)
geomean                  281.0n        231.8n       -17.53%

                  │ bench-master.txt │            bench-new.txt             │
                  │       B/op       │    B/op     vs base                  │
Protobuf/Decode-2        75.000 ± 0%   3.000 ± 0%  -96.00% (p=0.000 n=10)
Protobuf/Encode-2         5.000 ± 0%   5.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                   19.36        3.873       -80.00%
¹ all samples are equal

                  │ bench-master.txt │            bench-new.txt             │
                  │    allocs/op     │ allocs/op   vs base                  │
Protobuf/Decode-2         3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)
Protobuf/Encode-2         1.000 ± 0%   1.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                   1.732        1.000       -42.26%
¹ all samples are equal

pkg: github.com/abemedia/go-don/encoding/text
              │ bench-master.txt │            bench-new.txt             │
              │      sec/op      │    sec/op     vs base                │
Text/Decode-2        60.04n ± 5%    18.38n ± 3%  -69.39% (p=0.000 n=10)
Text/Encode-2        97.09n ± 2%   101.70n ± 3%   +4.75% (p=0.000 n=10)
geomean              76.35n         43.23n       -43.37%

              │ bench-master.txt │              bench-new.txt              │
              │       B/op       │    B/op     vs base                     │
Text/Decode-2         16.00 ± 0%    0.00 ± 0%  -100.00% (p=0.000 n=10)
Text/Encode-2         24.00 ± 0%   24.00 ± 0%         ~ (p=1.000 n=10) ¹
geomean               19.60                    ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

              │ bench-master.txt │              bench-new.txt              │
              │    allocs/op     │ allocs/op   vs base                     │
Text/Decode-2         1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
Text/Encode-2         2.000 ± 0%   2.000 ± 0%         ~ (p=1.000 n=10) ¹
geomean               1.414                    ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

pkg: github.com/abemedia/go-don/encoding/toml
              │ bench-master.txt │           bench-new.txt            │
              │      sec/op      │   sec/op     vs base               │
TOML/Decode-2        7.077µ ± 5%   7.303µ ± 3%       ~ (p=0.143 n=10)
TOML/Encode-2        1.956µ ± 3%   2.061µ ± 2%  +5.40% (p=0.007 n=10)
geomean              3.720µ        3.880µ       +4.29%

              │ bench-master.txt │             bench-new.txt             │
              │       B/op       │     B/op      vs base                 │
TOML/Decode-2       11.61Ki ± 0%   11.59Ki ± 0%  -0.13% (p=0.000 n=10)
TOML/Encode-2         752.0 ± 0%     752.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean             2.920Ki        2.918Ki       -0.07%
¹ all samples are equal

              │ bench-master.txt │            bench-new.txt            │
              │    allocs/op     │ allocs/op   vs base                 │
TOML/Decode-2         37.00 ± 0%   36.00 ± 0%  -2.70% (p=0.000 n=10)
TOML/Encode-2         16.00 ± 0%   16.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean               24.33        24.00       -1.36%
¹ all samples are equal

pkg: github.com/abemedia/go-don/encoding/xml
             │ bench-master.txt │           bench-new.txt            │
             │      sec/op      │   sec/op     vs base               │
XML/Decode-2        3.034µ ± 2%   2.985µ ± 7%       ~ (p=0.280 n=10)
XML/Encode-2        2.388µ ± 7%   2.273µ ± 6%  -4.84% (p=0.009 n=10)
geomean             2.692µ        2.604µ       -3.24%

             │ bench-master.txt │             bench-new.txt             │
             │       B/op       │     B/op      vs base                 │
XML/Decode-2       1.086Ki ± 0%   1.070Ki ± 0%  -1.44% (p=0.000 n=10)
XML/Encode-2       4.359Ki ± 0%   4.359Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean            2.176Ki        2.160Ki       -0.72%
¹ all samples are equal

             │ bench-master.txt │            bench-new.txt            │
             │    allocs/op     │ allocs/op   vs base                 │
XML/Decode-2         23.00 ± 0%   22.00 ± 0%  -4.35% (p=0.000 n=10)
XML/Encode-2         8.000 ± 0%   8.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean              13.56        13.27       -2.20%
¹ all samples are equal

pkg: github.com/abemedia/go-don/encoding/yaml
              │ bench-master.txt │           bench-new.txt            │
              │      sec/op      │   sec/op     vs base               │
YAML/Decode-2        7.234µ ± 3%   7.381µ ± 4%       ~ (p=0.353 n=10)
YAML/Encode-2        4.578µ ± 6%   4.655µ ± 4%       ~ (p=0.631 n=10)
geomean              5.755µ        5.861µ       +1.85%

              │ bench-master.txt │             bench-new.txt             │
              │       B/op       │     B/op      vs base                 │
YAML/Decode-2       6.602Ki ± 0%   6.586Ki ± 0%  -0.24% (p=0.000 n=10)
YAML/Encode-2       6.555Ki ± 0%   6.555Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean             6.578Ki        6.570Ki       -0.12%
¹ all samples are equal

              │ bench-master.txt │            bench-new.txt            │
              │    allocs/op     │ allocs/op   vs base                 │
YAML/Decode-2         42.00 ± 0%   41.00 ± 0%  -2.38% (p=0.000 n=10)
YAML/Encode-2         19.00 ± 0%   19.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean               28.25        27.91       -1.20%
¹ all samples are equal

@abemedia abemedia merged commit 827209b into master May 14, 2023
@abemedia abemedia deleted the perf/request-pool branch May 14, 2023 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant