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!: switch back to protons #327

Closed
wants to merge 4 commits into from
Closed

feat!: switch back to protons #327

wants to merge 4 commits into from

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Aug 15, 2022

Motivation

  • We should switch back to protons when it's performance is comparable or better than protobufjs
  • Prepare a branch to track the performance of different versions of protons

Description

Update Jul 2023: the performance is comparable to protobufjs with protons 5.1.0

protobuf
    ✔ decode Attestation message using protons 5.1.0                       3446018 ops/s    290.1900 ns/op        -    2053201 runs   60.1 s
    ✔ encode Attestation message using protons 5.1.0                       2506831 ops/s    398.9100 ns/op        -    1492091 runs   60.0 s

protobufjs

protobuf
    ✔ decode Attestation message using protobufjs                          3177024 ops/s    314.7600 ns/op   x0.960    1890821 runs   60.1 s
    ✔ encode Attestation message using protobufjs                          2500563 ops/s    399.9100 ns/op   x1.012    1485962 runs   60.0 s

Closes #453
Closes #318

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2022

Codecov Report

Patch coverage: 74.78% and project coverage change: -2.31% ⚠️

Comparison is base (23bf0ee) 82.30% compared to head (ba73f6a) 80.00%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
- Coverage   82.30%   80.00%   -2.31%     
==========================================
  Files          48       48              
  Lines       12039    11105     -934     
  Branches     1286     1152     -134     
==========================================
- Hits         9909     8884    -1025     
- Misses       2130     2221      +91     
Files Changed Coverage Δ
src/metrics.ts 16.43% <3.98%> (-2.57%) ⬇️
src/index.ts 70.11% <63.73%> (+0.14%) ⬆️
src/message/rpc.ts 88.05% <88.05%> (ø)
src/message/decodeRpc.ts 93.71% <94.24%> (+0.99%) ⬆️
src/message-cache.ts 78.06% <100.00%> (ø)
src/types.ts 94.57% <100.00%> (ø)
src/utils/buildRawMessage.ts 92.21% <100.00%> (ø)
src/utils/create-gossip-rpc.ts 100.00% <100.00%> (ø)
test/decodeRpc.spec.ts 100.00% <100.00%> (ø)
test/message-cache.spec.ts 100.00% <100.00%> (ø)
... and 2 more

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

@twoeths
Copy link
Contributor Author

twoeths commented Jul 31, 2023

not sure why using proton-runtime 5.1.0 the performance is 2x slower

protobuf
    ✔ decode Attestation message using protons 5.1.0                       1645793 ops/s    607.6100 ns/op        -     983127 runs   60.1 s
    ✔ encode Attestation message using protons 5.1.0                       1630497 ops/s    613.3100 ns/op        -     972079 runs   60.0 s

should be good to go with proton-runtime 3.1.0

@twoeths twoeths marked this pull request as ready for review July 31, 2023 10:00
@twoeths twoeths requested a review from a team as a code owner July 31, 2023 10:00
@twoeths twoeths changed the title feat: switch back to protons feat!: switch back to protons Aug 2, 2023
@twoeths
Copy link
Contributor Author

twoeths commented Aug 5, 2023

this is not ready, got memory leak issue as noted in #318 (comment)

@twoeths twoeths marked this pull request as draft August 5, 2023 06:12
@twoeths
Copy link
Contributor Author

twoeths commented Aug 16, 2023

rss is 1GB-1.5GB more than protobuf version, this is from a lodestar test mainnet node

Screenshot 2023-08-16 at 08 56 29
  message ControlPrune {
    optional string topicID = 1;
    repeated PeerInfo peers = 2;
    optional uint64 backoff = 3;
  }

while with protobuf it's mostly <=6.2GB. I think the main change is backoff field being intepreted as bigint while protobufjs used number instead

Screenshot 2023-08-16 at 09 00 44
 interface IControlPrune {

        /** ControlPrune topicID */
        topicID?: (string|null);

        /** ControlPrune peers */
        peers?: (RPC.IPeerInfo[]|null);

        /** ControlPrune backoff */
        backoff?: (number|null);
    }

@wemeetagain
Copy link
Member

https://github.com/ipfs-shipyard/protons-gossipsub-benchmark

@tuyennhv might be worth testing again with the latest protons

@twoeths
Copy link
Contributor Author

twoeths commented Oct 27, 2023

we'll need to go with latest protons 7 anyway in order to use backoff field as a number, track this work in #468 instead

@twoeths twoeths closed this Oct 27, 2023
@twoeths twoeths deleted the tuyen/protons branch October 27, 2023 08:59
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.

vuln prototype pollution in dependency protobufjs Add protons back
3 participants