Skip to content

chore(astria-merkle): add benchmarks#1179

Merged
Fraser999 merged 1 commit intomainfrom
fraser/merkle-benchmarks
Jun 18, 2024
Merged

chore(astria-merkle): add benchmarks#1179
Fraser999 merged 1 commit intomainfrom
fraser/merkle-benchmarks

Conversation

@Fraser999
Copy link
Contributor

Summary

Added benchmarks to astria-merkle using Divan.

Background

We wanted benchmarks to measure the performance of the crate, and to be able to spot performance regressions in the future.

I chose Divan over the more established Criterion for a few reasons:

  • benchmark tests can be added anywhere in the crate, similar to unit tests (Criterion cannot be used on functions in a binary crate)
  • simple API
  • clear output
  • can track allocation information

It is not without drawbacks though, most of which are identified as future plans for Divan:

  • no ability to use a baseline
  • const params are somewhat limiting (e.g. I couldn't use an enum as a const param)
  • not compatible with nextest (I added a simple workaround for now)

I also included benchmarks for a similar crate: ct-merkle which adheres to RFC 6962. The results show that generally our implementation is slightly faster across most input selections, and that it performs the same or fewer allocations.

Changes

  • Added benchmarks. These can include allocation info by running with the bench_include_allocs feature enabled.

Testing

These are tests.

Example of running `cargo bench -q -p astria-merkle` on my Ryzen 7900X
Timer precision: 10 ns
benchmark                           fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ five_leaves                                    │               │               │               │         │
│  ├─ empty_data                                  │               │               │               │         │
│  │  ├─ construct_proof_astria     240 ns        │ 906.5 ns      │ 252.7 ns      │ 275.1 ns      │ 100     │ 400
│  │  ├─ construct_proof_ct_merkle  312.7 ns      │ 430.5 ns      │ 325.5 ns      │ 328.6 ns      │ 100     │ 400
│  │  ├─ construct_tree_astria      710.7 ns      │ 2.118 µs      │ 721.2 ns      │ 739.4 ns      │ 100     │ 200
│  │  ├─ construct_tree_ct_merkle   781.7 ns      │ 1.021 µs      │ 791.7 ns      │ 799 ns        │ 100     │ 100
│  │  ├─ verify_leaf_astria         1.602 µs      │ 1.983 µs      │ 1.632 µs      │ 1.637 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      1.772 µs      │ 2.503 µs      │ 1.803 µs      │ 1.872 µs      │ 100     │ 100
│  ├─ mixed_sizes                                 │               │               │               │         │
│  │  ├─ construct_proof_astria     293 ns        │ 1.174 µs      │ 320.2 ns      │ 328.8 ns      │ 100     │ 400
│  │  ├─ construct_proof_ct_merkle  360.7 ns      │ 520.7 ns      │ 393 ns        │ 400 ns        │ 100     │ 200
│  │  ├─ construct_tree_astria      448.7 µs      │ 455 µs        │ 449 µs        │ 450.3 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   448.8 µs      │ 457 µs        │ 449.2 µs      │ 450.6 µs      │ 100     │ 100
│  │  ├─ verify_leaf_astria         449.6 µs      │ 461.3 µs      │ 450.3 µs      │ 451.6 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      426.8 µs      │ 455.5 µs      │ 450.7 µs      │ 449.5 µs      │ 100     │ 100
│  ├─ one_hundred_kb                              │               │               │               │         │
│  │  ├─ construct_proof_astria     252.7 ns      │ 313 ns        │ 269 ns        │ 271.7 ns      │ 100     │ 400
│  │  ├─ construct_proof_ct_merkle  305.2 ns      │ 463.2 ns      │ 320.5 ns      │ 323.7 ns      │ 100     │ 400
│  │  ├─ construct_tree_astria      184.5 µs      │ 187.8 µs      │ 184.8 µs      │ 185.2 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   184.7 µs      │ 188.9 µs      │ 184.9 µs      │ 185.5 µs      │ 100     │ 100
│  │  ├─ verify_leaf_astria         185.5 µs      │ 189.3 µs      │ 185.7 µs      │ 186.2 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      185.9 µs      │ 197.1 µs      │ 186.1 µs      │ 186.8 µs      │ 100     │ 100
│  ├─ one_kb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     245.2 ns      │ 292.7 ns      │ 262.7 ns      │ 263.6 ns      │ 100     │ 400
│  │  ├─ construct_proof_ct_merkle  255 ns        │ 478.2 ns      │ 262.7 ns      │ 268.4 ns      │ 100     │ 400
│  │  ├─ construct_tree_astria      2.463 µs      │ 2.694 µs      │ 2.493 µs      │ 2.494 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   2.533 µs      │ 3.035 µs      │ 2.554 µs      │ 2.56 µs       │ 100     │ 100
│  │  ├─ verify_leaf_astria         3.265 µs      │ 3.546 µs      │ 3.295 µs      │ 3.299 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      3.476 µs      │ 4.096 µs      │ 3.506 µs      │ 3.52 µs       │ 100     │ 100
│  ├─ one_mb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     252.7 ns      │ 385.5 ns      │ 271.5 ns      │ 276.6 ns      │ 100     │ 400
│  │  ├─ construct_proof_ct_merkle  389.7 ns      │ 1.191 µs      │ 410.7 ns      │ 431.9 ns      │ 100     │ 100
│  │  ├─ construct_tree_astria      1.845 ms      │ 1.856 ms      │ 1.849 ms      │ 1.849 ms      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   1.987 ms      │ 1.999 ms      │ 1.99 ms       │ 1.991 ms      │ 100     │ 100
│  │  ├─ verify_leaf_astria         1.988 ms      │ 2.037 ms      │ 1.992 ms      │ 1.993 ms      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      2.169 ms      │ 2.2 ms        │ 2.172 ms      │ 2.173 ms      │ 100     │ 100
│  ╰─ ten_bytes                                   │               │               │               │         │
│     ├─ construct_proof_astria     242.7 ns      │ 295.5 ns      │ 262.7 ns      │ 264.1 ns      │ 100     │ 400
│     ├─ construct_proof_ct_merkle  255.2 ns      │ 350.5 ns      │ 265.2 ns      │ 269.7 ns      │ 100     │ 400
│     ├─ construct_tree_astria      650.7 ns      │ 691.2 ns      │ 656.2 ns      │ 658.8 ns      │ 100     │ 200
│     ├─ construct_tree_ct_merkle   741.2 ns      │ 821.7 ns      │ 755.7 ns      │ 755.4 ns      │ 100     │ 200
│     ├─ verify_leaf_astria         1.461 µs      │ 4.027 µs      │ 1.482 µs      │ 1.525 µs      │ 100     │ 100
│     ╰─ verify_leaf_ct_merkle      1.652 µs      │ 2.032 µs      │ 1.672 µs      │ 1.686 µs      │ 100     │ 100
├─ one_hundred_leaves                             │               │               │               │         │
│  ├─ empty_data                                  │               │               │               │         │
│  │  ├─ construct_proof_astria     9.377 µs      │ 14.07 µs      │ 9.783 µs      │ 9.957 µs      │ 100     │ 100
│  │  ├─ construct_proof_ct_merkle  11.33 µs      │ 19.59 µs      │ 11.4 µs       │ 11.71 µs      │ 100     │ 100
│  │  ├─ construct_tree_astria      28.4 µs       │ 31.03 µs      │ 28.45 µs      │ 28.51 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   31.34 µs      │ 35.99 µs      │ 31.39 µs      │ 31.52 µs      │ 100     │ 100
│  │  ├─ verify_leaf_astria         64.11 µs      │ 69.03 µs      │ 64.32 µs      │ 64.78 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      71.82 µs      │ 77.83 µs      │ 71.96 µs      │ 72.5 µs       │ 100     │ 100
│  ├─ mixed_sizes                                 │               │               │               │         │
│  │  ├─ construct_proof_astria     10.13 µs      │ 16.64 µs      │ 10.86 µs      │ 11.35 µs      │ 100     │ 100
│  │  ├─ construct_proof_ct_merkle  12.54 µs      │ 17.76 µs      │ 13.68 µs      │ 13.59 µs      │ 100     │ 100
│  │  ├─ construct_tree_astria      6.156 ms      │ 6.171 ms      │ 6.159 ms      │ 6.16 ms       │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   6.722 ms      │ 6.842 ms      │ 6.736 ms      │ 6.739 ms      │ 100     │ 100
│  │  ├─ verify_leaf_astria         6.738 ms      │ 7.035 ms      │ 6.771 ms      │ 6.78 ms       │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      6.618 ms      │ 6.719 ms      │ 6.65 ms       │ 6.653 ms      │ 100     │ 100
│  ├─ one_hundred_kb                              │               │               │               │         │
│  │  ├─ construct_proof_astria     9.578 µs      │ 13.86 µs      │ 10.04 µs      │ 10.36 µs      │ 100     │ 100
│  │  ├─ construct_proof_ct_merkle  11.92 µs      │ 18.46 µs      │ 12.14 µs      │ 12.64 µs      │ 100     │ 100
│  │  ├─ construct_tree_astria      3.712 ms      │ 3.726 ms      │ 3.717 ms      │ 3.717 ms      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   3.716 ms      │ 3.731 ms      │ 3.72 ms       │ 3.72 ms       │ 100     │ 100
│  │  ├─ verify_leaf_astria         3.754 ms      │ 3.771 ms      │ 3.758 ms      │ 3.758 ms      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      3.766 ms      │ 3.79 ms       │ 3.771 ms      │ 3.772 ms      │ 100     │ 100
│  ├─ one_kb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     9.367 µs      │ 13.04 µs      │ 9.753 µs      │ 9.839 µs      │ 100     │ 100
│  │  ├─ construct_proof_ct_merkle  10.91 µs      │ 20.22 µs      │ 11.01 µs      │ 11.44 µs      │ 100     │ 100
│  │  ├─ construct_tree_astria      64.47 µs      │ 68.9 µs       │ 64.52 µs      │ 64.75 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   68.07 µs      │ 79.11 µs      │ 68.13 µs      │ 68.5 µs       │ 100     │ 100
│  │  ├─ verify_leaf_astria         101.2 µs      │ 114.5 µs      │ 101.6 µs      │ 102.2 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      109.8 µs      │ 131.6 µs      │ 110.2 µs      │ 110.9 µs      │ 100     │ 100
│  ├─ one_mb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     10.51 µs      │ 20.26 µs      │ 13.15 µs      │ 12.92 µs      │ 100     │ 100
│  │  ├─ construct_proof_ct_merkle  14.54 µs      │ 20.58 µs      │ 15.3 µs       │ 15.48 µs      │ 100     │ 100
│  │  ├─ construct_tree_astria      36.92 ms      │ 37.04 ms      │ 36.94 ms      │ 36.94 ms      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   40.07 ms      │ 40.83 ms      │ 40.3 ms       │ 40.33 ms      │ 100     │ 100
│  │  ├─ verify_leaf_astria         40.41 ms      │ 41.64 ms      │ 40.81 ms      │ 40.81 ms      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      45.39 ms      │ 46.9 ms       │ 45.57 ms      │ 45.61 ms      │ 100     │ 100
│  ╰─ ten_bytes                                   │               │               │               │         │
│     ├─ construct_proof_astria     8.525 µs      │ 12.76 µs      │ 9.227 µs      │ 9.46 µs       │ 100     │ 100
│     ├─ construct_proof_ct_merkle  10.99 µs      │ 16.23 µs      │ 12.01 µs      │ 12.23 µs      │ 100     │ 100
│     ├─ construct_tree_astria      28.5 µs       │ 31.75 µs      │ 28.58 µs      │ 28.69 µs      │ 100     │ 100
│     ├─ construct_tree_ct_merkle   32.34 µs      │ 35.34 µs      │ 32.42 µs      │ 32.54 µs      │ 100     │ 100
│     ├─ verify_leaf_astria         65.68 µs      │ 72.36 µs      │ 66.7 µs       │ 66.97 µs      │ 100     │ 100
│     ╰─ verify_leaf_ct_merkle      74 µs         │ 79.62 µs      │ 74.63 µs      │ 75.22 µs      │ 100     │ 100
├─ one_leaf                                       │               │               │               │         │
│  ├─ empty_data                                  │               │               │               │         │
│  │  ├─ construct_proof_astria     8.954 ns      │ 9.118 ns      │ 9.032 ns      │ 9.045 ns      │ 100     │ 12800
│  │  ├─ construct_proof_ct_merkle  6.215 ns      │ 6.532 ns      │ 6.294 ns      │ 6.286 ns      │ 100     │ 25600
│  │  ├─ construct_tree_astria      52.7 ns       │ 57.7 ns       │ 53.32 ns      │ 53.41 ns      │ 100     │ 3200
│  │  ├─ construct_tree_ct_merkle   59.26 ns      │ 77.76 ns      │ 60.23 ns      │ 60.46 ns      │ 100     │ 3200
│  │  ├─ verify_leaf_astria         61.73 ns      │ 63.04 ns      │ 62.42 ns      │ 62.42 ns      │ 100     │ 1600
│  │  ╰─ verify_leaf_ct_merkle      63.61 ns      │ 68.04 ns      │ 64.29 ns      │ 64.47 ns      │ 100     │ 1600
│  ├─ mixed_sizes                                 │               │               │               │         │
│  │  ├─ construct_proof_astria     9.032 ns      │ 9.891 ns      │ 9.036 ns      │ 9.068 ns      │ 100     │ 12800
│  │  ├─ construct_proof_ct_merkle  6.215 ns      │ 6.298 ns      │ 6.255 ns      │ 6.246 ns      │ 100     │ 25600
│  │  ├─ construct_tree_astria      413 ns        │ 418 ns        │ 415.5 ns      │ 415.7 ns      │ 100     │ 400
│  │  ├─ construct_tree_ct_merkle   420.7 ns      │ 430.5 ns      │ 425.5 ns      │ 424.7 ns      │ 100     │ 400
│  │  ├─ verify_leaf_astria         425.5 ns      │ 445.5 ns      │ 425.7 ns      │ 426.8 ns      │ 100     │ 400
│  │  ╰─ verify_leaf_ct_merkle      428 ns        │ 438.2 ns      │ 433 ns        │ 432.5 ns      │ 100     │ 400
│  ├─ one_hundred_kb                              │               │               │               │         │
│  │  ├─ construct_proof_astria     9.032 ns      │ 12.48 ns      │ 9.11 ns       │ 9.156 ns      │ 100     │ 12800
│  │  ├─ construct_proof_ct_merkle  6.255 ns      │ 7.583 ns      │ 6.411 ns      │ 6.548 ns      │ 100     │ 25600
│  │  ├─ construct_tree_astria      36.77 µs      │ 40.37 µs      │ 36.8 µs       │ 36.94 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   36.78 µs      │ 39.83 µs      │ 36.81 µs      │ 36.92 µs      │ 100     │ 100
│  │  ├─ verify_leaf_astria         36.78 µs      │ 39.71 µs      │ 36.81 µs      │ 36.93 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      36.79 µs      │ 40.57 µs      │ 36.82 µs      │ 36.93 µs      │ 100     │ 100
│  ├─ one_kb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     9.032 ns      │ 9.423 ns      │ 9.032 ns      │ 9.049 ns      │ 100     │ 12800
│  │  ├─ construct_proof_ct_merkle  6.215 ns      │ 6.294 ns      │ 6.255 ns      │ 6.245 ns      │ 100     │ 25600
│  │  ├─ construct_tree_astria      413 ns        │ 418.2 ns      │ 415.5 ns      │ 415.6 ns      │ 100     │ 400
│  │  ├─ construct_tree_ct_merkle   420.5 ns      │ 473.2 ns      │ 423 ns        │ 425.6 ns      │ 100     │ 400
│  │  ├─ verify_leaf_astria         425.5 ns      │ 440.5 ns      │ 428 ns        │ 427.6 ns      │ 100     │ 400
│  │  ╰─ verify_leaf_ct_merkle      428 ns        │ 435.7 ns      │ 430.5 ns      │ 430.7 ns      │ 100     │ 400
│  ├─ one_mb                                      │               │               │               │         │
│  │  ├─ construct_proof_astria     9.11 ns       │ 14.04 ns      │ 9.266 ns      │ 9.297 ns      │ 100     │ 12800
│  │  ├─ construct_proof_ct_merkle  7.313 ns      │ 30.32 ns      │ 8.758 ns      │ 9.16 ns       │ 100     │ 12800
│  │  ├─ construct_tree_astria      367.4 µs      │ 373.3 µs      │ 367.7 µs      │ 368.7 µs      │ 100     │ 100
│  │  ├─ construct_tree_ct_merkle   367.4 µs      │ 375 µs        │ 367.8 µs      │ 368.7 µs      │ 100     │ 100
│  │  ├─ verify_leaf_astria         367.5 µs      │ 371.9 µs      │ 367.8 µs      │ 368.8 µs      │ 100     │ 100
│  │  ╰─ verify_leaf_ct_merkle      367.4 µs      │ 372.3 µs      │ 367.8 µs      │ 368.9 µs      │ 100     │ 100
│  ╰─ ten_bytes                                   │               │               │               │         │
│     ├─ construct_proof_astria     9.032 ns      │ 9.118 ns      │ 9.032 ns      │ 9.051 ns      │ 100     │ 12800
│     ├─ construct_proof_ct_merkle  6.215 ns      │ 6.606 ns      │ 6.294 ns      │ 6.386 ns      │ 100     │ 25600
│     ├─ construct_tree_astria      54.89 ns      │ 120.3 ns      │ 54.92 ns      │ 55.84 ns      │ 100     │ 3200
│     ├─ construct_tree_ct_merkle   64.92 ns      │ 70.61 ns      │ 66.17 ns      │ 66.14 ns      │ 100     │ 1600
│     ├─ verify_leaf_astria         66.17 ns      │ 68.67 ns      │ 66.79 ns      │ 66.8 ns       │ 100     │ 1600
│     ╰─ verify_leaf_ct_merkle      73.04 ns      │ 150.7 ns      │ 74.92 ns      │ 75.9 ns       │ 100     │ 1600
╰─ twenty_leaves                                  │               │               │               │         │
   ├─ empty_data                                  │               │               │               │         │
   │  ├─ construct_proof_astria     1.482 µs      │ 2.564 µs      │ 1.542 µs      │ 1.601 µs      │ 100     │ 100
   │  ├─ construct_proof_ct_merkle  1.893 µs      │ 4.337 µs      │ 1.943 µs      │ 2.023 µs      │ 100     │ 100
   │  ├─ construct_tree_astria      4.036 µs      │ 4.186 µs      │ 4.057 µs      │ 4.058 µs      │ 100     │ 100
   │  ├─ construct_tree_ct_merkle   4.387 µs      │ 7.693 µs      │ 4.407 µs      │ 4.454 µs      │ 100     │ 100
   │  ├─ verify_leaf_astria         9.186 µs      │ 11.47 µs      │ 9.226 µs      │ 9.281 µs      │ 100     │ 100
   │  ╰─ verify_leaf_ct_merkle      10.36 µs      │ 13.05 µs      │ 10.4 µs       │ 10.46 µs      │ 100     │ 100
   ├─ mixed_sizes                                 │               │               │               │         │
   │  ├─ construct_proof_astria     1.602 µs      │ 2.814 µs      │ 1.672 µs      │ 1.711 µs      │ 100     │ 100
   │  ├─ construct_proof_ct_merkle  2.012 µs      │ 2.704 µs      │ 2.123 µs      │ 2.142 µs      │ 100     │ 100
   │  ├─ construct_tree_astria      1.231 ms      │ 1.237 ms      │ 1.232 ms      │ 1.233 ms      │ 100     │ 100
   │  ├─ construct_tree_ct_merkle   1.232 ms      │ 1.237 ms      │ 1.233 ms      │ 1.233 ms      │ 100     │ 100
   │  ├─ verify_leaf_astria         1.238 ms      │ 1.243 ms      │ 1.238 ms      │ 1.239 ms      │ 100     │ 100
   │  ╰─ verify_leaf_ct_merkle      1.239 ms      │ 1.356 ms      │ 1.24 ms       │ 1.242 ms      │ 100     │ 100
   ├─ one_hundred_kb                              │               │               │               │         │
   │  ├─ construct_proof_astria     1.572 µs      │ 2.273 µs      │ 1.622 µs      │ 1.663 µs      │ 100     │ 100
   │  ├─ construct_proof_ct_merkle  1.973 µs      │ 3.095 µs      │ 2.053 µs      │ 2.085 µs      │ 100     │ 100
   │  ├─ construct_tree_astria      739.5 µs      │ 744.4 µs      │ 742.4 µs      │ 741.8 µs      │ 100     │ 100
   │  ├─ construct_tree_ct_merkle   739.9 µs      │ 744.5 µs      │ 743 µs        │ 742.4 µs      │ 100     │ 100
   │  ├─ verify_leaf_astria         745.9 µs      │ 750.6 µs      │ 749 µs        │ 748.4 µs      │ 100     │ 100
   │  ╰─ verify_leaf_ct_merkle      747.5 µs      │ 758.9 µs      │ 750.6 µs      │ 750.1 µs      │ 100     │ 100
   ├─ one_kb                                      │               │               │               │         │
   │  ├─ construct_proof_astria     1.622 µs      │ 2.273 µs      │ 1.712 µs      │ 1.72 µs       │ 100     │ 100
   │  ├─ construct_proof_ct_merkle  2.003 µs      │ 2.614 µs      │ 2.053 µs      │ 2.073 µs      │ 100     │ 100
   │  ├─ construct_tree_astria      11.18 µs      │ 13.8 µs       │ 11.2 µs       │ 11.26 µs      │ 100     │ 100
   │  ├─ construct_tree_ct_merkle   11.66 µs      │ 15.7 µs       │ 11.69 µs      │ 11.73 µs      │ 100     │ 100
   │  ├─ verify_leaf_astria         16.7 µs       │ 19.78 µs      │ 16.77 µs      │ 16.86 µs      │ 100     │ 100
   │  ╰─ verify_leaf_ct_merkle      17.79 µs      │ 21.36 µs      │ 17.88 µs      │ 18.04 µs      │ 100     │ 100
   ├─ one_mb                                      │               │               │               │         │
   │  ├─ construct_proof_astria     1.582 µs      │ 2.614 µs      │ 1.722 µs      │ 1.765 µs      │ 100     │ 100
   │  ├─ construct_proof_ct_merkle  2.032 µs      │ 4.307 µs      │ 2.174 µs      │ 2.288 µs      │ 100     │ 100
   │  ├─ construct_tree_astria      7.378 ms      │ 7.544 ms      │ 7.381 ms      │ 7.383 ms      │ 100     │ 100
   │  ├─ construct_tree_ct_merkle   7.378 ms      │ 7.392 ms      │ 7.382 ms      │ 7.383 ms      │ 100     │ 100
   │  ├─ verify_leaf_astria         7.385 ms      │ 7.554 ms      │ 7.389 ms      │ 7.392 ms      │ 100     │ 100
   │  ╰─ verify_leaf_ct_merkle      8.214 ms      │ 8.533 ms      │ 8.239 ms      │ 8.249 ms      │ 100     │ 100
   ╰─ ten_bytes                                   │               │               │               │         │
      ├─ construct_proof_astria     1.482 µs      │ 2.534 µs      │ 1.572 µs      │ 1.639 µs      │ 100     │ 100
      ├─ construct_proof_ct_merkle  1.863 µs      │ 2.614 µs      │ 1.902 µs      │ 1.937 µs      │ 100     │ 100
      ├─ construct_tree_astria      4.017 µs      │ 6.161 µs      │ 4.037 µs      │ 4.067 µs      │ 100     │ 100
      ├─ construct_tree_ct_merkle   4.497 µs      │ 4.839 µs      │ 4.528 µs      │ 4.531 µs      │ 100     │ 100
      ├─ verify_leaf_astria         9.297 µs      │ 13.53 µs      │ 9.416 µs      │ 9.548 µs      │ 100     │ 100
      ╰─ verify_leaf_ct_merkle      10.47 µs      │ 14.73 µs      │ 10.56 µs      │ 10.68 µs      │ 100     │ 100

Related Issues

Closes #1176.

@Fraser999 Fraser999 requested a review from a team as a code owner June 12, 2024 17:33
@Fraser999 Fraser999 requested a review from SuperFluffy June 12, 2024 17:33
@github-actions github-actions bot added the conductor pertaining to the astria-conductor crate label Jun 12, 2024
Copy link
Contributor

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice to have, thank you!

Another nice bench would be looking at how the leaves of our tree can be constructed ad-hoc by writing their bytes directly into a hasher. We actually make use of this inside sequencer because we construct proofs over data included in a block by using (rollup_id || rollup_data) and this way we avoid allocating byte vectors for every single leaf.

@Fraser999 Fraser999 added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit 273e50e Jun 18, 2024
@Fraser999 Fraser999 deleted the fraser/merkle-benchmarks branch June 18, 2024 14:21
steezeburger added a commit that referenced this pull request Jun 19, 2024
* main:
  chore(bridge-withdrawer): add missing errors and clean up names (#1178)
  feat(sequencer): add ttl and invalid cache to app mempool (#1138)
  chore(astria-merkle): add benchmarks (#1179)
  chore(sequencer-relayer): add timeout to gRPCs to Celestia app (#1191)
  refactor(core): parse ics20 denoms as ibc or trace prefixed variants (#1181)
  Mycodecrafting/sequencer seed node (#1188)
  chore: register all metrics during startup (#1144)
  feat(charts): option to purge geth mempool (#1182)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conductor pertaining to the astria-conductor crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Benchmark astria-merkle

2 participants