Skip to content

perf: apply masking key 8 bytes at a time#58

Merged
mccutchen merged 1 commit intomainfrom
perf/applymask
Sep 11, 2025
Merged

perf: apply masking key 8 bytes at a time#58
mccutchen merged 1 commit intomainfrom
perf/applymask

Conversation

@mccutchen
Copy link
Owner

@mccutchen mccutchen commented Sep 11, 2025

Basically what it says on the tin. Key results from the benchmarks below, indicating ~35% faster read/write frame and and ~55% higher throughput:

                  │ ./baseline/bench-results.txt │       ./head/bench-results.txt       │
                  │            sec/op            │    sec/op     vs base                │
ReadFrame/1KiB-4                     867.5n ± 3%   575.8n ±  4%  -33.63% (p=0.000 n=10)
ReadFrame/1MiB-4                     550.2µ ± 1%   331.0µ ± 18%  -39.84% (p=0.000 n=10)
WriteFrame/1KiB-4                    932.5n ± 0%   675.9n ±  0%  -27.51% (p=0.000 n=10)
WriteFrame/1MiB-4                    588.4µ ± 4%   336.3µ ±  4%  -42.84% (p=0.000 n=10)
geomean                              22.62µ        14.43µ        -36.22%

                  │ ./baseline/bench-results.txt │       ./head/bench-results.txt        │
                  │             B/s              │      B/s       vs base                │
ReadFrame/1KiB-4                    1.109Gi ± 3%   1.671Gi ±  4%  +50.67% (p=0.000 n=10)
ReadFrame/1MiB-4                    1.775Gi ± 1%   2.950Gi ± 15%  +66.22% (p=0.000 n=10)
WriteFrame/1KiB-4                   1.032Gi ± 0%   1.423Gi ±  0%  +37.95% (p=0.000 n=10)
WriteFrame/1MiB-4                   1.660Gi ± 3%   2.904Gi ±  3%  +74.97% (p=0.000 n=10)
geomean                             1.355Gi        2.125Gi        +56.80%

@github-actions
Copy link

🔥 Run benchmarks comparing 547619b against main:

gh workflow run bench.yaml -f pr_number=58

Note: this comment will update with each new commit.

@github-actions
Copy link

benchstats: d74cdf7...547619b

View full benchmark output on the workflow summary.

goos: linux
goarch: amd64
pkg: github.com/mccutchen/websocket
cpu: AMD EPYC 7763 64-Core Processor                
                  │ ./baseline/bench-results.txt │       ./head/bench-results.txt       │
                  │            sec/op            │    sec/op     vs base                │
ReadFrame/1KiB-4                     867.5n ± 3%   575.8n ±  4%  -33.63% (p=0.000 n=10)
ReadFrame/1MiB-4                     550.2µ ± 1%   331.0µ ± 18%  -39.84% (p=0.000 n=10)
WriteFrame/1KiB-4                    932.5n ± 0%   675.9n ±  0%  -27.51% (p=0.000 n=10)
WriteFrame/1MiB-4                    588.4µ ± 4%   336.3µ ±  4%  -42.84% (p=0.000 n=10)
geomean                              22.62µ        14.43µ        -36.22%

                  │ ./baseline/bench-results.txt │       ./head/bench-results.txt        │
                  │             B/s              │      B/s       vs base                │
ReadFrame/1KiB-4                    1.109Gi ± 3%   1.671Gi ±  4%  +50.67% (p=0.000 n=10)
ReadFrame/1MiB-4                    1.775Gi ± 1%   2.950Gi ± 15%  +66.22% (p=0.000 n=10)
WriteFrame/1KiB-4                   1.032Gi ± 0%   1.423Gi ±  0%  +37.95% (p=0.000 n=10)
WriteFrame/1MiB-4                   1.660Gi ± 3%   2.904Gi ±  3%  +74.97% (p=0.000 n=10)
geomean                             1.355Gi        2.125Gi        +56.80%

                  │ ./baseline/bench-results.txt │       ./head/bench-results.txt        │
                  │             B/op             │     B/op      vs base                 │
ReadFrame/1KiB-4                    1.164Ki ± 0%   1.164Ki ± 0%       ~ (p=1.000 n=10) ¹
ReadFrame/1MiB-4                    1.008Mi ± 0%   1.008Mi ± 0%       ~ (p=0.056 n=10)
WriteFrame/1KiB-4                   1.125Ki ± 0%   1.125Ki ± 0%       ~ (p=1.000 n=10) ¹
WriteFrame/1MiB-4                   1.008Mi ± 0%   1.008Mi ± 0%       ~ (p=0.057 n=10)
geomean                             34.37Ki        34.37Ki       -0.00%
¹ all samples are equal

                  │ ./baseline/bench-results.txt │      ./head/bench-results.txt       │
                  │          allocs/op           │ allocs/op   vs base                 │
ReadFrame/1KiB-4                      5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=10) ¹
ReadFrame/1MiB-4                      5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=10) ¹
WriteFrame/1KiB-4                     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
WriteFrame/1MiB-4                     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                               2.236        2.236       +0.00%
¹ all samples are equal

@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (d74cdf7) to head (547619b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #58   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files           2        2           
  Lines         496      496           
=======================================
  Hits          461      461           
  Misses         28       28           
  Partials        7        7           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mccutchen mccutchen merged commit 7aee74c into main Sep 11, 2025
16 of 17 checks passed
@mccutchen mccutchen deleted the perf/applymask branch September 11, 2025 08:29
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