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: calculate the main chain height more efficiently #237

Merged
merged 5 commits into from
Jul 26, 2023

Conversation

ielashi
Copy link
Collaborator

@ielashi ielashi commented Jul 26, 2023

The Bitcoin testnet's metrics endpoint ran out of cycles because it had a large number of unstable blocks, and computing the main chain height under those conditions was very expensive.

This commit makes that computation more efficient. Prior to this change, the get_metrics benchmark took 163_059_419 cycles. Now it takes 8_102_095.

Adds a benchmark to gauge how many instructions it takes to run the
`get_metrics` endpoint when there is a large number of stable blocks.

The output of `benchmarks/run.sh` is currently:

```
(1_519_453_070 : nat64) <-- benchmark for `insert_300_blocks`
(163_059_419 : nat64) <-- benchmark for `get_metrics`
```
The Bitcoin testnet's metrics endpoint ran out of cycles because it had
a large number of unstable blocks, and computing the main chain height
under those conditions was very expensive.

This commit makes that computation more efficient. Prior to this change,
the `get_metrics` benchmark took `163_059_419` cycles. Now it takes
`8_102_095`.
@ielashi ielashi requested a review from a team as a code owner July 26, 2023 14:35
Base automatically changed from ielashi/metrics_benchmark to master July 26, 2023 15:02
@ielashi ielashi merged commit 32bf6fc into master Jul 26, 2023
21 checks passed
@ielashi ielashi deleted the ielashi/speed_up_metrics branch July 26, 2023 15:03
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.

2 participants