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: stream-decoder, metadata #2733

Draft
wants to merge 9 commits into
base: @grpc/grpc-js@1.10.x
Choose a base branch
from

Conversation

AVVS
Copy link
Contributor

@AVVS AVVS commented Apr 30, 2024

Was working on optimizing small sized unary request handling and this is what the work resulted into. It's not finished by any means, but seems pretty promising to me

Initial approach was to test this with h2load and pre-generated payload, but results were fluctuating depending on the mood of the machine (sort of expected). Decided to write smaller benchmarks focusing on specific parts that could be improved

Have to investigate why cached decoder class looses performance (deopt due to something?)
changing benchmark runner fixed the problem

LMK if there is some immediate feedback

======================
  grpc-js benchmarks
======================

Platform info:
==============
   Darwin 23.4.0 arm64
   Node.JS: 20.12.2
   V8: 11.3.244.8-node.19
   CPU: Apple M1 Max × 10
   Memory: 64 GB

Suite: fromHttp2Headers
=======================

✔ 1.10.6      1,588,332 ops/sec
✔ current     2,600,138 ops/sec

   1.10.6        -38.91%   (1,588,332 ops/sec)   (avg: 629ns)
   current            0%   (2,600,138 ops/sec)   (avg: 384ns)

┌─────────┬────────────────────────────────────────────────────┐
│ 1.10.6  │ ███████████████████████████████                    │
├─────────┼────────────────────────────────────────────────────┤
│ current │ ██████████████████████████████████████████████████ │
└─────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: fromHttp2Headers + common operations
===========================================

✔ 1.10.6      1,382,671 ops/sec
✔ current     1,912,055 ops/sec

   1.10.6        -27.69%   (1,382,671 ops/sec)   (avg: 723ns)
   current            0%   (1,912,055 ops/sec)   (avg: 522ns)

┌─────────┬────────────────────────────────────────────────────┐
│ 1.10.6  │ ████████████████████████████████████               │
├─────────┼────────────────────────────────────────────────────┤
│ current │ ██████████████████████████████████████████████████ │
└─────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: toHttp2Headers
=====================

✔ 1.10.6     11,711,356 ops/sec
✔ current    13,824,638 ops/sec

   1.10.6        -15.29%   (11,711,356 ops/sec)   (avg: 85ns)
   current            0%   (13,824,638 ops/sec)   (avg: 72ns)

┌─────────┬────────────────────────────────────────────────────┐
│ 1.10.6  │ ██████████████████████████████████████████         │
├─────────┼────────────────────────────────────────────────────┤
│ current │ ██████████████████████████████████████████████████ │
└─────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: Small Payload
====================

✔ 1.10.6             1,795,930 ops/sec
✔ 1.10.6 cached      1,767,710 ops/sec
✔ current            5,401,762 ops/sec
✔ current cached     6,795,307 ops/sec

   1.10.6               -73.57%   (1,795,930 ops/sec)   (avg: 556ns)
   1.10.6 cached        -73.99%   (1,767,710 ops/sec)   (avg: 565ns)
   current              -20.51%   (5,401,762 ops/sec)   (avg: 185ns)
   current cached            0%   (6,795,307 ops/sec)   (avg: 147ns)

┌────────────────┬────────────────────────────────────────────────────┐
│ 1.10.6         │ █████████████                                      │
├────────────────┼────────────────────────────────────────────────────┤
│ 1.10.6 cached  │ █████████████                                      │
├────────────────┼────────────────────────────────────────────────────┤
│ current        │ ████████████████████████████████████████           │
├────────────────┼────────────────────────────────────────────────────┤
│ current cached │ ██████████████████████████████████████████████████ │
└────────────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: Small Payload Chunked
============================

✔ 1.10.6             1,385,919 ops/sec
✔ 1.10.6 cached      1,524,966 ops/sec
✔ current            2,180,954 ops/sec
✔ current cached     2,376,207 ops/sec

   1.10.6               -41.68%   (1,385,919 ops/sec)   (avg: 721ns)
   1.10.6 cached        -35.82%   (1,524,966 ops/sec)   (avg: 655ns)
   current               -8.22%   (2,180,954 ops/sec)   (avg: 458ns)
   current cached            0%   (2,376,207 ops/sec)   (avg: 420ns)

┌────────────────┬────────────────────────────────────────────────────┐
│ 1.10.6         │ █████████████████████████████                      │
├────────────────┼────────────────────────────────────────────────────┤
│ 1.10.6 cached  │ ████████████████████████████████                   │
├────────────────┼────────────────────────────────────────────────────┤
│ current        │ ██████████████████████████████████████████████     │
├────────────────┼────────────────────────────────────────────────────┤
│ current cached │ ██████████████████████████████████████████████████ │
└────────────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: Large Payload
====================

✔ 1.10.6                71,714 ops/sec
✔ 1.10.6 cached         70,454 ops/sec
✔ current              151,911 ops/sec
✔ current cached       152,948 ops/sec

   1.10.6               -53.11%     (71,714 ops/sec)   (avg: 13μs)
   1.10.6 cached        -53.94%     (70,454 ops/sec)   (avg: 14μs)
   current               -0.68%    (151,911 ops/sec)   (avg: 6μs)
   current cached            0%    (152,948 ops/sec)   (avg: 6μs)

┌────────────────┬────────────────────────────────────────────────────┐
│ 1.10.6         │ ███████████████████████                            │
├────────────────┼────────────────────────────────────────────────────┤
│ 1.10.6 cached  │ ███████████████████████                            │
├────────────────┼────────────────────────────────────────────────────┤
│ current        │ ██████████████████████████████████████████████████ │
├────────────────┼────────────────────────────────────────────────────┤
│ current cached │ ██████████████████████████████████████████████████ │
└────────────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

Suite: Large Payload Chunked
============================

✔ 1.10.6                69,420 ops/sec
✔ 1.10.6 cached         68,879 ops/sec
✔ current               70,607 ops/sec
✔ current cached        70,040 ops/sec

   1.10.6                -1.68%     (69,420 ops/sec)   (avg: 14μs)
   1.10.6 cached         -2.45%     (68,879 ops/sec)   (avg: 14μs)
   current                   0%     (70,607 ops/sec)   (avg: 14μs)
   current cached         -0.8%     (70,040 ops/sec)   (avg: 14μs)

┌────────────────┬────────────────────────────────────────────────────┐
│ 1.10.6         │ █████████████████████████████████████████████████  │
├────────────────┼────────────────────────────────────────────────────┤
│ 1.10.6 cached  │ █████████████████████████████████████████████████  │
├────────────────┼────────────────────────────────────────────────────┤
│ current        │ ██████████████████████████████████████████████████ │
├────────────────┼────────────────────────────────────────────────────┤
│ current cached │ ██████████████████████████████████████████████████ │
└────────────────┴────────────────────────────────────────────────────┘
-----------------------------------------------------------------------

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