vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
242 stars 52 forks source link

Avoid unnecessary rate limit message copy #1067

Closed arnetheduck closed 3 months ago

arnetheduck commented 3 months ago

The way the code is written, a new Opt instance is created for every RPC message processed by gossipsub - this involves copying the full message even though only the size is needed for rate limiting purposes - in Nimbus, this becomes a performance/memory allocation hotspot.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.56%. Comparing base (08a48fa) to head (fac3fb4).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1067/graphs/tree.svg?width=650&height=150&src=pr&token=UR5JRQ249W&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im)](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1067?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im) ```diff @@ Coverage Diff @@ ## unstable #1067 +/- ## ============================================ - Coverage 82.56% 82.56% -0.01% ============================================ Files 91 91 Lines 15814 15806 -8 ============================================ - Hits 13057 13050 -7 + Misses 2757 2756 -1 ``` | [Files](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1067?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im) | Coverage Δ | | |---|---|---| | [libp2p/protocols/pubsub/gossipsub.nim](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1067?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvZ29zc2lwc3ViLm5pbQ==) | `86.80% <100.00%> (-0.24%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1067/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im)
codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.83%. Comparing base (d1e51be) to head (e469c14). Report is 1 commits behind head on unstable.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1067/graphs/tree.svg?width=650&height=150&src=pr&token=M88zHaQffJ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1067?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) ```diff @@ Coverage Diff @@ ## unstable #1067 +/- ## ========================================= Coverage 84.83% 84.83% ========================================= Files 91 91 Lines 15403 15395 -8 ========================================= - Hits 13067 13061 -6 + Misses 2336 2334 -2 ``` | [Files](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1067?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) | Coverage Δ | | |---|---|---| | [libp2p/protocols/pubsub/gossipsub.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1067?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvZ29zc2lwc3ViLm5pbQ==) | `86.77% <100.00%> (-0.25%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1067/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)
diegomrsantos commented 3 months ago

Thanks for that, looks much better now anyway IMO.