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

[scratchpad] sophisticated Criterion benchmarks #8388

Merged
merged 3 commits into from
May 14, 2021

Conversation

msmouse
Copy link

@msmouse msmouse commented May 12, 2021

Motivation

(This is on top of #8386, including its two commits before it got landed.)

Based on the NaiveSmt newly introduced, benchmark the updating time in these three cases: 1. inserting to an empty SMT; 2. inserting to an SMT with a committed base (root is "unknown" hence all information about the base tree must be known through the proof reader; 3. updating an SMT with some in mem nodes.

The NaiveSmt is under the feature "bench", and when running the bench "--features bench" needs to be in the command line, which is not ideal. Probably NaiveSmt needs to be split into its own crate.

Have you read the Contributing Guidelines on pull requests?

Y

Test Plan

benchmark updated

cargo bench -p scratchpad --features bench

    Finished bench [optimized + debuginfo] target(s) in 9.68s
     Running target/release/deps/scratchpad-7c837bd6e47fcdb2

running 18 tests
test sparse_merkle::sparse_merkle_test::test_batch_update_construct_subtree_from_proofs ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_at_bottom_found_empty_node ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_at_bottom_found_internal_node ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_at_bottom_found_leaf_node ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_at_bottom_found_subtree_node ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_panic ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_three_siblings ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_with_new_leaf_create_extension ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_with_new_leaf_override_existing_leaf ... ignored
test sparse_merkle::sparse_merkle_test::test_construct_subtree_zero_siblings ... ignored
test sparse_merkle::sparse_merkle_test::test_drop ... ignored
test sparse_merkle::sparse_merkle_test::test_new_empty ... ignored
test sparse_merkle::sparse_merkle_test::test_new_subtree ... ignored
test sparse_merkle::sparse_merkle_test::test_read_partial_tree_from_storage ... ignored
test sparse_merkle::sparse_merkle_test::test_update ... ignored
test sparse_merkle::sparse_merkle_test::test_update_256_siblings_in_proof ... ignored
test sparse_merkle::sparse_merkle_test::test_update_consistency ... ignored
test sparse_merkle::sparse_merkle_test::test_update_consistency_batches ... ignored

test result: ok. 0 passed; 0 failed; 18 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running target/release/deps/sparse_merkle-55c0c17a2ae2a8fb
WARNING: HTML report generation will become a non-default optional feature in Criterion.rs 0.4.0.
This feature is being moved to cargo-criterion (https://github.com/bheisler/cargo-criterion) and will be optional in a future version of Criterion.rs. To silence this warning, either switch to cargo-criterion or enable the 'html_reports' feature in your Cargo.toml.

insert to empty/serial_update/100
                        time:   [13.527 ms 14.292 ms 15.105 ms]
                        thrpt:  [6.6204 Kelem/s 6.9967 Kelem/s 7.3928 Kelem/s]
Found 9 outliers among 100 measurements (9.00%)
  5 (5.00%) high mild
  4 (4.00%) high severe
Benchmarking insert to empty/batches_update/100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.7s, enable flat sampling, or reduce sample count to 50.
insert to empty/batches_update/100
                        time:   [1.3015 ms 1.3039 ms 1.3064 ms]
                        thrpt:  [76.549 Kelem/s 76.695 Kelem/s 76.832 Kelem/s]
Found 13 outliers among 100 measurements (13.00%)
  6 (6.00%) high mild
  7 (7.00%) high severe
insert to empty/batch_update/100
                        time:   [714.19 us 717.26 us 720.35 us]
                        thrpt:  [138.82 Kelem/s 139.42 Kelem/s 140.02 Kelem/s]
Found 5 outliers among 100 measurements (5.00%)
  1 (1.00%) low mild
  3 (3.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to empty/serial_update/1000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 14.9s, or reduce sample count to 30.
insert to empty/serial_update/1000
                        time:   [142.65 ms 143.26 ms 143.89 ms]
                        thrpt:  [6.9500 Kelem/s 6.9802 Kelem/s 7.0103 Kelem/s]
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) low mild
  3 (3.00%) high mild
insert to empty/batches_update/1000
                        time:   [16.868 ms 16.891 ms 16.918 ms]
                        thrpt:  [59.108 Kelem/s 59.203 Kelem/s 59.286 Kelem/s]
Found 9 outliers among 100 measurements (9.00%)
  2 (2.00%) high mild
  7 (7.00%) high severe
insert to empty/batch_update/1000
                        time:   [2.6954 ms 2.7105 ms 2.7255 ms]
                        thrpt:  [366.91 Kelem/s 368.94 Kelem/s 371.00 Kelem/s]
Benchmarking insert to empty/serial_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 142.0s, or reduce sample count to 10.
insert to empty/serial_update/10000
                        time:   [1.4500 s 1.4596 s 1.4698 s]
                        thrpt:  [6.8036 Kelem/s 6.8513 Kelem/s 6.8967 Kelem/s]
Found 10 outliers among 100 measurements (10.00%)
  10 (10.00%) high mild
Benchmarking insert to empty/batches_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 21.1s, or reduce sample count to 20.
insert to empty/batches_update/10000
                        time:   [208.66 ms 208.80 ms 208.95 ms]
                        thrpt:  [47.858 Kelem/s 47.893 Kelem/s 47.926 Kelem/s]
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe
insert to empty/batch_update/10000
                        time:   [16.936 ms 17.012 ms 17.087 ms]
                        thrpt:  [585.24 Kelem/s 587.82 Kelem/s 590.45 Kelem/s]
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) low mild
  1 (1.00%) high mild

insert to committed base/serial_update/100
                        time:   [15.525 ms 15.672 ms 15.823 ms]
                        thrpt:  [6.3200 Kelem/s 6.3808 Kelem/s 6.4411 Kelem/s]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
insert to committed base/batches_update/100
                        time:   [5.1969 ms 5.2011 ms 5.2058 ms]
                        thrpt:  [19.209 Kelem/s 19.227 Kelem/s 19.242 Kelem/s]
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe
insert to committed base/batch_update/100
                        time:   [2.3438 ms 2.3577 ms 2.3724 ms]
                        thrpt:  [42.151 Kelem/s 42.414 Kelem/s 42.665 Kelem/s]
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to committed base/serial_update/1000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 16.5s, or reduce sample count to 30.
insert to committed base/serial_update/1000
                        time:   [160.16 ms 161.07 ms 161.99 ms]
                        thrpt:  [6.1732 Kelem/s 6.2084 Kelem/s 6.2438 Kelem/s]
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) low mild
  3 (3.00%) high mild
insert to committed base/batches_update/1000
                        time:   [48.654 ms 48.798 ms 48.984 ms]
                        thrpt:  [20.415 Kelem/s 20.493 Kelem/s 20.553 Kelem/s]
Found 14 outliers among 100 measurements (14.00%)
  2 (2.00%) low mild
  2 (2.00%) high mild
  10 (10.00%) high severe
insert to committed base/batch_update/1000
                        time:   [10.939 ms 10.994 ms 11.051 ms]
                        thrpt:  [90.489 Kelem/s 90.959 Kelem/s 91.413 Kelem/s]
Found 6 outliers among 100 measurements (6.00%)
  6 (6.00%) high mild
Benchmarking insert to committed base/serial_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 157.4s, or reduce sample count to 10.
insert to committed base/serial_update/10000
                        time:   [1.6184 s 1.6249 s 1.6319 s]
                        thrpt:  [6.1280 Kelem/s 6.1541 Kelem/s 6.1790 Kelem/s]
Found 12 outliers among 100 measurements (12.00%)
  1 (1.00%) low mild
  10 (10.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to committed base/batches_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 43.6s, or reduce sample count to 10.
Benchmarking insert to committed base/batches_update/10000: Collecting 100 samples in estimated 43.649 s (100 iterations                                                                                                                        insert to committed base/batches_update/10000
                        time:   [432.45 ms 432.68 ms 432.92 ms]
                        thrpt:  [23.099 Kelem/s 23.112 Kelem/s 23.124 Kelem/s]
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) low mild
  1 (1.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to committed base/batch_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.4s, or reduce sample count to 60.
insert to committed base/batch_update/10000
                        time:   [73.519 ms 73.856 ms 74.205 ms]
                        thrpt:  [134.76 Kelem/s 135.40 Kelem/s 136.02 Kelem/s]
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild

insert to uncommitted base/serial_update/100
                        time:   [16.507 ms 16.651 ms 16.791 ms]
                        thrpt:  [5.9557 Kelem/s 6.0057 Kelem/s 6.0581 Kelem/s]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) low mild
Benchmarking insert to uncommitted base/batches_update/100: Collecting 100 samples in estimated 5.2687 s (1000 iteration                                                                                                                        insert to uncommitted base/batches_update/100
                        time:   [5.2638 ms 5.2699 ms 5.2765 ms]
                        thrpt:  [18.952 Kelem/s 18.976 Kelem/s 18.998 Kelem/s]
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to uncommitted base/batch_update/100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.7s, enable flat sampling, or reduce sample count to 50.
insert to uncommitted base/batch_update/100
                        time:   [1.5108 ms 1.5228 ms 1.5348 ms]
                        thrpt:  [65.155 Kelem/s 65.668 Kelem/s 66.190 Kelem/s]
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) low mild
  2 (2.00%) high mild
  1 (1.00%) high severe
Benchmarking insert to uncommitted base/serial_update/1000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 16.3s, or reduce sample count to 30.
Benchmarking insert to uncommitted base/serial_update/1000: Collecting 100 samples in estimated 16.289 s (100 iterations                                                                                                                        insert to uncommitted base/serial_update/1000
                        time:   [159.49 ms 160.18 ms 160.86 ms]
                        thrpt:  [6.2166 Kelem/s 6.2431 Kelem/s 6.2701 Kelem/s]
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) low mild
  3 (3.00%) high mild
Benchmarking insert to uncommitted base/batches_update/1000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 5.0s, or reduce sample count to 90.
Benchmarking insert to uncommitted base/batches_update/1000: Collecting 100 samples in estimated 5.0392 s (100 iteration                                                                                                                        insert to uncommitted base/batches_update/1000
                        time:   [50.327 ms 50.364 ms 50.400 ms]
                        thrpt:  [19.841 Kelem/s 19.855 Kelem/s 19.870 Kelem/s]
Found 11 outliers among 100 measurements (11.00%)
  2 (2.00%) low severe
  6 (6.00%) low mild
  3 (3.00%) high mild
insert to uncommitted base/batch_update/1000
                        time:   [7.7170 ms 7.7643 ms 7.8120 ms]
                        thrpt:  [128.01 Kelem/s 128.79 Kelem/s 129.58 Kelem/s]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking insert to uncommitted base/serial_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 166.1s, or reduce sample count to 10.
Benchmarking insert to uncommitted base/serial_update/10000: Collecting 100 samples in estimated 166.09 s (100 iteration                                                                                                                        insert to uncommitted base/serial_update/10000
                        time:   [1.5330 s 1.5563 s 1.5776 s]
                        thrpt:  [6.3387 Kelem/s 6.4257 Kelem/s 6.5234 Kelem/s]
Found 16 outliers among 100 measurements (16.00%)
  13 (13.00%) low severe
  2 (2.00%) low mild
  1 (1.00%) high mild
Benchmarking insert to uncommitted base/batches_update/10000: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 44.5s, or reduce sample count to 10.
Benchmarking insert to uncommitted base/batches_update/10000: Collecting 100 samples in estimated 44.509 s (100 iteratio                                                                                                                        insert to uncommitted base/batches_update/10000
                        time:   [440.94 ms 441.28 ms 441.63 ms]
                        thrpt:  [22.643 Kelem/s 22.661 Kelem/s 22.679 Kelem/s]
Benchmarking insert to uncommitted base/batch_update/10000: Collecting 100 samples in estimated 9.1737 s (200 iterations                                                                                                                        insert to uncommitted base/batch_update/10000
                        time:   [45.539 ms 45.720 ms 45.902 ms]
                        thrpt:  [217.85 Kelem/s 218.72 Kelem/s 219.59 Kelem/s]

Related PRs

#8386

}

criterion_group!(benches, insert_to_empty);
// criterion_group!(benches, insert_to_empty, update_exiting_keys_out_of_1mil);
Copy link
Contributor

Choose a reason for hiding this comment

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

delete?

group.finish();

fn gen_value(rng: &mut StdRng) -> AccountStateBlob {
rng.gen::<[u8; 32]>().to_vec().into()
Copy link
Contributor

Choose a reason for hiding this comment

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

too small?

Copy link
Author

Choose a reason for hiding this comment

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

It's planned that the global SMT leaves carry account "authenticator"s which are hash values.

Copy link
Author

Choose a reason for hiding this comment

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

Actually.. that plus the chaining structure. I'l do 100bytes then.

@msmouse msmouse force-pushed the naive_bench branch 2 times, most recently from 2e60178 to 069ca8f Compare May 13, 2021 22:50
@msmouse
Copy link
Author

msmouse commented May 14, 2021

/land

@bors-libra bors-libra moved this from In Review to Queued in bors May 14, 2021
Check generate root hash and proofs with this so that we don't need to rely on the DB (the JellyFish indeed) in tests and benchmarks. The update interface of the JellyFish might change and depend on the scratchpad instead.
Based on the NaiveSmt newly introduced, benchmark the updating time in these three cases: 1. inserting to an empty SMT; 2. inserting to an SMT with a committed base (root is "unknown" hence all information about the base tree must be known through the proof reader; 3. updating an SMT with some in mem nodes.

Closes: diem#8388
@bors-libra bors-libra moved this from Queued to Testing in bors May 14, 2021
@github-actions
Copy link

Cluster Test Result

Test runner setup time spent 277 secs
Compatibility test results for land_9dbc1cf0 ==> land_e098af37 (PR)
1. All instances running land_9dbc1cf0, generating some traffic on network
2. First full node land_9dbc1cf0 ==> land_e098af37, to validate new full node to old validator node traffic
3. First Validator node land_9dbc1cf0 ==> land_e098af37, to validate storage compatibility
4. First batch validators (14) land_9dbc1cf0 ==> land_e098af37, to test consensus and traffic between old full nodes and new validator node
5. First batch full nodes (14) land_9dbc1cf0 ==> land_e098af37
6. Second batch validators (15) land_9dbc1cf0 ==> land_e098af37, to upgrade rest of the validators
7. Second batch of full nodes (15) land_9dbc1cf0 ==> land_e098af37, to finish the network upgrade, time spent 685 secs
all up : 873 TPS, 5207 ms latency, 5950 ms p99 latency, no expired txns, time spent 250 secs
Logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-05-14T03:33:25Z',to:'2021-05-14T03:56:20Z'))
Dashboard: http://grafana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/d/performance/performance?from=1620963205000&to=1620964580000
Validator 1 logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-05-14T03:33:25Z',to:'2021-05-14T03:56:20Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_9dbc1cf0 --cluster-test-tag land_e098af37 -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_e098af37 --report report.json --suite land_blocking_compat

🎉 Land-blocking cluster test passed! 👌

@bors-libra bors-libra removed this from Testing in bors May 14, 2021
@bors-libra bors-libra merged commit e098af3 into diem:main May 14, 2021
@bors-libra bors-libra temporarily deployed to Sccache May 14, 2021 03:56 Inactive
@bors-libra bors-libra temporarily deployed to Docker May 14, 2021 03:56 Inactive
@bors-libra bors-libra temporarily deployed to Docker May 14, 2021 14:21 Inactive
zgfzgf pushed a commit to zgfzgf/diem that referenced this pull request Jun 8, 2021
Based on the NaiveSmt newly introduced, benchmark the updating time in these three cases: 1. inserting to an empty SMT; 2. inserting to an SMT with a committed base (root is "unknown" hence all information about the base tree must be known through the proof reader; 3. updating an SMT with some in mem nodes.

Closes: diem#8388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants