near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.31k stars 605 forks source link

tool(congestion) - Added benchmark command for bootstrapping #11598

Closed wacban closed 1 month ago

wacban commented 1 month ago

Adding a tool for measuring the time it takes to run bootstrapping. This relies on existence of flat storage so in order to avoid needing to hunt for congestion I add some receipts to the queue directly. This is meant to be ran on an mainnet node to simulate execution on a real database.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0.95238% with 104 lines in your changes missing coverage. Please review.

Project coverage is 71.46%. Comparing base (8d349d6) to head (df32228).

Files Patch % Lines
tools/state-viewer/src/congestion_control.rs 0.95% 101 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #11598 +/- ## ========================================== - Coverage 71.50% 71.46% -0.04% ========================================== Files 788 788 Lines 160606 160697 +91 Branches 160606 160697 +91 ========================================== + Hits 114839 114845 +6 - Misses 40759 40841 +82 - Partials 5008 5011 +3 ``` | [Flag](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | Coverage Δ | | |---|---|---| | [backward-compatibility](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [db-migration](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [genesis-check](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.36% <0.95%> (-0.01%)` | :arrow_down: | | [integration-tests](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `37.69% <0.00%> (-0.02%)` | :arrow_down: | | [linux](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `68.88% <0.95%> (-0.04%)` | :arrow_down: | | [linux-nightly](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `70.94% <0.95%> (-0.05%)` | :arrow_down: | | [macos](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `50.92% <0.95%> (-1.63%)` | :arrow_down: | | [pytests](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.59% <0.95%> (-0.01%)` | :arrow_down: | | [sanity-checks](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.39% <0.95%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `66.15% <0.95%> (-0.05%)` | :arrow_down: | | [upgradability](https://app.codecov.io/gh/near/nearcore/pull/11598/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.28% <0.95%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

wacban commented 1 month ago

@jakmeier I split the benchmarking into two separate commands so that it's forced to go through the db. Thanks for catching the lack of commit, this was it. Also applied other commits and did some refactoring.

wacban commented 1 month ago

First data point: Bootstrapping of 10k 10kB receipts takes ~2s on an mainnet RPC node. This should be the upper bound as it's executed in the standalone command whereas in practice we may benefit from caches.

0 - V1(CongestionInfoV1 { delayed_receipts_gas: 0, buffered_receipts_gas: 0, receipt_bytes: 101060000, allowed_shard: 0 }) - 2.208872722s
wacban commented 1 month ago

@jakmeier I'm going to merge this as is but please let me know if you have any other comments and I'll follow up.

jakmeier commented 1 month ago

@jakmeier I'm going to merge this as is but please let me know if you have any other comments and I'll follow up.

Only one question: What happens with the receipts afterwards? I guess they stay in the database forever? I know it's not something we expect anyone to run on their production system but it might still make sense to at least mention in the description of the command.

wacban commented 1 month ago

Only one question: What happens with the receipts afterwards? I guess they stay in the database forever? I know it's not something we expect anyone to run on their production system but it might still make sense to at least mention in the description of the command.

Yeah, the database should be considered corrupted. I did mention it in a comment on the PrepareBenchmark cmd. Still let me add some extra warning and a confirmation from the user.