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

feat(encoding)!: simplify encoding interface and reduce allocs #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abemedia
Copy link
Owner

@abemedia abemedia commented Apr 1, 2024

No description provided.

Copy link
Contributor

github-actions bot commented Apr 1, 2024

Benchmark Results

.
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don
cpu: AMD EPYC 7763 64-Core Processor                
                         │   before    │                after                │
                         │   sec/op    │   sec/op     vs base                │
Handler/Request-4          309.2n ± 1%   251.1n ± 1%  -18.82% (p=0.000 n=10)
Handler/RequestPointer-4   330.4n ± 0%   257.2n ± 1%  -22.13% (p=0.000 n=10)
geomean                    319.6n        254.1n       -20.49%

                         │   before   │               after                │
                         │    B/op    │    B/op     vs base                │
Handler/Request-4          40.00 ± 0%   24.00 ± 0%  -40.00% (p=0.000 n=10)
Handler/RequestPointer-4   40.00 ± 0%   24.00 ± 0%  -40.00% (p=0.000 n=10)
geomean                    40.00        24.00       -40.00%

                         │   before   │               after                │
                         │ allocs/op  │ allocs/op   vs base                │
Handler/Request-4          2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
Handler/RequestPointer-4   2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
geomean                    2.000        1.000       -50.00%
encoding/json
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/json
cpu: AMD EPYC 7763 64-Core Processor                
              │   before    │                after                │
              │   sec/op    │   sec/op     vs base                │
JSON/Decode-4   89.70n ± 2%   79.64n ± 2%  -11.21% (p=0.000 n=10)
JSON/Encode-4   130.6n ± 0%   122.1n ± 5%   -6.54% (p=0.000 n=10)
geomean         108.3n        98.61n        -8.91%

              │   before   │                after                 │
              │    B/op    │    B/op     vs base                  │
JSON/Decode-4   16.00 ± 0%   16.00 ± 0%        ~ (p=1.000 n=10) ¹
JSON/Encode-4   32.00 ± 0%   16.00 ± 0%  -50.00% (p=0.000 n=10)
geomean         22.63        16.00       -29.29%
¹ all samples are equal

              │   before   │                after                 │
              │ allocs/op  │ allocs/op   vs base                  │
JSON/Decode-4   1.000 ± 0%   1.000 ± 0%        ~ (p=1.000 n=10) ¹
JSON/Encode-4   2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
geomean         1.414        1.000       -29.29%
¹ all samples are equal
encoding/msgpack
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/msgpack
cpu: AMD EPYC 7763 64-Core Processor                
                 │   before    │                after                │
                 │   sec/op    │   sec/op     vs base                │
Msgpack/Decode-4   289.1n ± 1%   240.9n ± 4%  -16.66% (p=0.000 n=10)
Msgpack/Encode-4   271.5n ± 0%   281.8n ± 2%   +3.79% (p=0.000 n=10)
geomean            280.1n        260.5n        -6.99%

                 │   before    │                after                 │
                 │    B/op     │    B/op     vs base                  │
Msgpack/Decode-4   51.000 ± 0%   3.000 ± 0%  -94.12% (p=0.000 n=10)
Msgpack/Encode-4    128.0 ± 0%   128.0 ± 0%        ~ (p=1.000 n=10) ¹
geomean             80.80        19.60       -75.75%
¹ all samples are equal

                 │   before   │                after                 │
                 │ allocs/op  │ allocs/op   vs base                  │
Msgpack/Decode-4   2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)
Msgpack/Encode-4   3.000 ± 0%   3.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean            2.449        1.732       -29.29%
¹ all samples are equal
encoding/protobuf
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/protobuf
cpu: AMD EPYC 7763 64-Core Processor                
                  │    before    │                after                │
                  │    sec/op    │   sec/op     vs base                │
Protobuf/Decode-4    160.7n ± 1%   140.4n ± 3%  -12.63% (p=0.000 n=10)
Protobuf/Encode-4   106.40n ± 0%   94.61n ± 4%  -11.08% (p=0.000 n=10)
geomean              130.8n        115.3n       -11.86%

                  │   before   │                after                │
                  │    B/op    │    B/op     vs base                 │
Protobuf/Decode-4   3.000 ± 0%   3.000 ± 0%       ~ (p=1.000 n=10) ¹
Protobuf/Encode-4   5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean             3.873        3.873       +0.00%
¹ all samples are equal

                  │   before   │                after                │
                  │ allocs/op  │ allocs/op   vs base                 │
Protobuf/Decode-4   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
Protobuf/Encode-4   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean             1.000        1.000       +0.00%
¹ all samples are equal
encoding/text
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/text
cpu: AMD EPYC 7763 64-Core Processor                
              │   before    │                after                │
              │   sec/op    │   sec/op     vs base                │
Text/Decode-4   11.79n ± 0%   11.78n ± 1%        ~ (p=0.467 n=10)
Text/Encode-4   35.49n ± 0%   39.25n ± 2%  +10.58% (p=0.000 n=10)
geomean         20.46n        21.50n        +5.11%

              │    before    │                after                │
              │     B/op     │    B/op     vs base                 │
Text/Decode-4   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Text/Encode-4   16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

              │    before    │                after                │
              │  allocs/op   │ allocs/op   vs base                 │
Text/Decode-4   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Text/Encode-4   1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
encoding/toml
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/toml
cpu: AMD EPYC 7763 64-Core Processor                
              │   before    │               after                │
              │   sec/op    │   sec/op     vs base               │
TOML/Decode-4   4.514µ ± 1%   4.508µ ± 3%       ~ (p=0.468 n=10)
TOML/Encode-4   1.286µ ± 0%   1.378µ ± 2%  +7.12% (p=0.000 n=10)
geomean         2.409µ        2.492µ       +3.43%

              │    before    │                 after                 │
              │     B/op     │     B/op      vs base                 │
TOML/Decode-4   11.59Ki ± 0%   11.55Ki ± 0%  -0.40% (p=0.000 n=10)
TOML/Encode-4     752.0 ± 0%     752.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean         2.918Ki        2.912Ki       -0.20%
¹ all samples are equal

              │   before   │                after                │
              │ allocs/op  │ allocs/op   vs base                 │
TOML/Decode-4   36.00 ± 0%   35.00 ± 0%  -2.78% (p=0.000 n=10)
TOML/Encode-4   16.00 ± 0%   16.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean         24.00        23.66       -1.40%
¹ all samples are equal
encoding/xml
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/xml
cpu: AMD EPYC 7763 64-Core Processor                
             │   before    │                after                │
             │   sec/op    │   sec/op     vs base                │
XML/Decode-4   1.902µ ± 2%   2.724µ ± 1%  +43.22% (p=0.000 n=10)
XML/Encode-4   1.401µ ± 1%   1.424µ ± 1%   +1.68% (p=0.000 n=10)
geomean        1.632µ        1.970µ       +20.67%

             │    before    │                 after                  │
             │     B/op     │     B/op      vs base                  │
XML/Decode-4   1.070Ki ± 0%   1.297Ki ± 0%  +21.17% (p=0.000 n=10)
XML/Encode-4   4.359Ki ± 0%   4.359Ki ± 0%        ~ (p=1.000 n=10) ¹
geomean        2.160Ki        2.378Ki       +10.08%
¹ all samples are equal

             │   before   │                after                 │
             │ allocs/op  │ allocs/op   vs base                  │
XML/Decode-4   22.00 ± 0%   28.00 ± 0%  +27.27% (p=0.000 n=10)
XML/Encode-4   8.000 ± 0%   8.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean        13.27        14.97       +12.82%
¹ all samples are equal
encoding/yaml
goos: linux
goarch: amd64
pkg: github.com/abemedia/go-don/encoding/yaml
cpu: AMD EPYC 7763 64-Core Processor                
              │   before    │               after                │
              │   sec/op    │   sec/op     vs base               │
YAML/Decode-4   4.845µ ± 3%   4.818µ ± 3%       ~ (p=0.072 n=10)
YAML/Encode-4   2.982µ ± 1%   3.034µ ± 3%  +1.74% (p=0.000 n=10)
geomean         3.801µ        3.823µ       +0.59%

              │    before    │                 after                 │
              │     B/op     │     B/op      vs base                 │
YAML/Decode-4   6.586Ki ± 0%   6.586Ki ± 0%       ~ (p=1.000 n=10) ¹
YAML/Encode-4   6.556Ki ± 0%   6.556Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean         6.571Ki        6.571Ki       +0.00%
¹ all samples are equal

              │   before   │                after                │
              │ allocs/op  │ allocs/op   vs base                 │
YAML/Decode-4   41.00 ± 0%   41.00 ± 0%       ~ (p=1.000 n=10) ¹
YAML/Encode-4   19.00 ± 0%   19.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean         27.91        27.91       +0.00%
¹ all samples are equal

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.53%. Comparing base (3f53fd0) to head (48b4280).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #214      +/-   ##
==========================================
+ Coverage   98.49%   98.53%   +0.03%     
==========================================
  Files          24       24              
  Lines         732      752      +20     
==========================================
+ Hits          721      741      +20     
  Misses          6        6              
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abemedia abemedia force-pushed the feat/encoding-simplify branch 3 times, most recently from 6ad184a to 35a023f Compare April 4, 2024 06:17
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.

None yet

1 participant