chore(benchmarks): call-requests and call-results benchmarks (#759)

This commit is contained in:
Ivan Boldyrev 2023-11-27 21:01:14 +04:00 committed by GitHub
parent 97be08e900
commit 2b83ad1755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1623 additions and 719 deletions

4
Cargo.lock generated
View File

@ -98,10 +98,12 @@ version = "0.6.0"
dependencies = [
"blake3",
"cid",
"digest 0.10.7",
"multihash 0.18.1",
"serde",
"serde_json",
"sha2 0.10.7",
"thiserror",
]
[[package]]
@ -778,6 +780,7 @@ dependencies = [
"cc",
"cfg-if 1.0.0",
"constant_time_eq 0.3.0",
"digest 0.10.7",
]
[[package]]
@ -1773,6 +1776,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer 0.10.4",
"crypto-common",
"subtle",
]
[[package]]

View File

@ -35,7 +35,6 @@ use air_interpreter_interface::CallRequestParams;
use air_parser::ast;
use air_trace_handler::merger::MergerCallResult;
use air_trace_handler::TraceHandler;
use air_utils::measure;
use std::rc::Rc;
@ -162,11 +161,7 @@ impl<'i> ResolvedCall<'i> {
tetraplets,
} = self.resolve_args(exec_ctx)?;
let serialized_tetraplets = measure!(
serde_json::to_string(&tetraplets).expect("default serializer shouldn't fail"),
tracing::Level::INFO,
"serde_json::to_string(tetraplets)",
);
let serialized_tetraplets = serde_json::to_string(&tetraplets).expect("default serializer shouldn't fail");
let request_params = CallRequestParams::new(
tetraplet.service_id.to_string(),

File diff suppressed because it is too large Load Diff

View File

@ -642,153 +642,179 @@ Machine c1f3ea5950db0a10b44da931c25774d64ab25084f47d504f72f311e694550ff1:
execute: 29.00µs
new: 38.00µs
Machine d77ebe8481884bc3b2778c8083f1bf459e548e929edd87041beb14f6b868d35f:
Platform: macOS-14.0-arm64-arm-64bit
Timestamp: 2023-11-06 18:49:22.923773+00:00
AquaVM version: 0.53.0
Platform: macOS-14.1.1-arm64-arm-64bit
Timestamp: 2023-11-27 15:04:01.881477+00:00
AquaVM version: 0.54.0
Benches:
Features: check_signatures,gen_signatures
big_values_data (8.59ms; 58.938 MiB, 58.938 MiB): Loading a trace with huge values
air::runner::execute_air: 8.59ms
preparation_step::preparation::parse_data: 4.79ms
from_slice: 4.74ms
preparation_step::preparation::prepare: 170.00µs
air::preparation_step::preparation::make_exec_ctx: 14.00µs
air_parser::parser::air_parser::parse: 33.00µs
runner::execute: 13.00µs
runner::farewell: 3.25ms
from_success_result: 3.23ms
populate_outcome_from_contexts: 3.19ms
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 85.00µs
verify: 13.00µs
canon-map-key-by-lens (11.57ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 11.57ms
preparation_step::preparation::parse_data: 3.11ms
from_slice: 3.06ms
preparation_step::preparation::prepare: 382.00µs
air::preparation_step::preparation::make_exec_ctx: 185.00µs
air_parser::parser::air_parser::parse: 74.00µs
runner::execute: 1.92ms
runner::farewell: 1.83ms
from_success_result: 1.81ms
populate_outcome_from_contexts: 1.46ms
signing_step::sign_produced_cids: 95.00µs
verification_step::verify: 4.07ms
verify: 3.72ms
canon-map-key-element-by-lens (11.55ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 11.55ms
preparation_step::preparation::parse_data: 3.10ms
from_slice: 3.06ms
preparation_step::preparation::prepare: 379.00µs
air::preparation_step::preparation::make_exec_ctx: 184.00µs
air_parser::parser::air_parser::parse: 74.00µs
runner::execute: 1.90ms
runner::farewell: 1.81ms
from_success_result: 1.79ms
populate_outcome_from_contexts: 1.46ms
signing_step::sign_produced_cids: 95.00µs
verification_step::verify: 4.08ms
verify: 3.73ms
canon-map-multiple-keys (9.83ms; 54.500 MiB, 54.500 MiB): benchmarking a map insert operation
air::runner::execute_air: 9.83ms
preparation_step::preparation::parse_data: 397.00µs
from_slice: 352.00µs
preparation_step::preparation::prepare: 196.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 58.00µs
runner::execute: 6.93ms
runner::farewell: 1.62ms
from_success_result: 1.60ms
populate_outcome_from_contexts: 1.31ms
signing_step::sign_produced_cids: 96.00µs
verification_step::verify: 405.00µs
verify: 50.00µs
canon-map-scalar-multiple-keys (4.05ms; 53.125 MiB, 53.125 MiB): benchmarking a map insert operation
air::runner::execute_air: 4.05ms
preparation_step::preparation::parse_data: 400.00µs
from_slice: 354.00µs
preparation_step::preparation::prepare: 200.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 60.00µs
runner::execute: 2.42ms
runner::farewell: 350.00µs
from_success_result: 331.00µs
populate_outcome_from_contexts: 294.00µs
signing_step::sign_produced_cids: 95.00µs
verification_step::verify: 404.00µs
verify: 50.00µs
canon-map-scalar-single-key (3.27ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 3.27ms
preparation_step::preparation::parse_data: 412.00µs
from_slice: 364.00µs
preparation_step::preparation::prepare: 193.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 55.00µs
runner::execute: 1.58ms
runner::farewell: 356.00µs
from_success_result: 336.00µs
populate_outcome_from_contexts: 283.00µs
signing_step::sign_produced_cids: 95.00µs
verification_step::verify: 447.00µs
verify: 92.00µs
canon-map-single-key (8.25ms; 55.312 MiB, 55.312 MiB): benchmarking a map insert operation
air::runner::execute_air: 8.25ms
preparation_step::preparation::parse_data: 414.00µs
from_slice: 366.00µs
preparation_step::preparation::prepare: 193.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 56.00µs
runner::execute: 5.19ms
runner::farewell: 1.71ms
from_success_result: 1.69ms
populate_outcome_from_contexts: 1.45ms
signing_step::sign_produced_cids: 96.00µs
verification_step::verify: 449.00µs
verify: 95.00µs
dashboard (6.74ms; 52.625 MiB, 52.625 MiB): big dashboard test
air::runner::execute_air: 6.74ms
preparation_step::preparation::parse_data: 1.00ms
from_slice: 947.00µs
preparation_step::preparation::prepare: 318.00µs
air::preparation_step::preparation::make_exec_ctx: 32.00µs
air_parser::parser::air_parser::parse: 163.00µs
runner::execute: 1.70ms
to_string(tetraplets): 362.00µs
runner::farewell: 462.00µs
from_success_result: 442.00µs
populate_outcome_from_contexts: 399.00µs
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 2.97ms
verify: 215.00µs
long_data (3.64ms; 53.750 MiB, 53.750 MiB): Long data trace
air::runner::execute_air: 3.64ms
preparation_step::preparation::parse_data: 1.77ms
from_slice: 1.72ms
preparation_step::preparation::prepare: 172.00µs
air::preparation_step::preparation::make_exec_ctx: 14.00µs
big-values-data (13.01ms; 59.000 MiB, 59.000 MiB): Loading a trace with huge values
air::runner::execute_air: 13.01ms
preparation_step::preparation::parse_data: 5.24ms
from_slice: 5.18ms
preparation_step::preparation::prepare: 173.00µs
air::preparation_step::preparation::make_exec_ctx: 22.00µs
air_parser::parser::air_parser::parse: 30.00µs
runner::execute: 12.00µs
runner::farewell: 926.00µs
from_success_result: 906.00µs
populate_outcome_from_contexts: 867.00µs
signing_step::sign_produced_cids: 102.00µs
verification_step::verify: 529.00µs
verify: 10.00µs
multiple-cids10 (2.63ms; 52.438 MiB, 52.438 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 2.63ms
preparation_step::preparation::parse_data: 417.00µs
from_slice: 363.00µs
preparation_step::preparation::prepare: 205.00µs
air::preparation_step::preparation::make_exec_ctx: 26.00µs
air_parser::parser::air_parser::parse: 58.00µs
runner::execute: 446.00µs
to_string(tetraplets): 10.00µs
runner::farewell: 321.00µs
from_success_result: 300.00µs
populate_outcome_from_contexts: 252.00µs
runner::execute: 13.00µs
runner::farewell: 3.27ms
from_success_result: 3.25ms
populate_outcome_from_contexts: 3.22ms
signing_step::sign_produced_cids: 99.00µs
verification_step::verify: 4.03ms
verify: 3.67ms
call-requests500 (25.80ms; 58.562 MiB, 58.562 MiB): multiple call requests
air::runner::execute_air: 25.80ms
preparation_step::preparation::parse_data: 146.00µs
from_slice: 106.00µs
preparation_step::preparation::prepare: 253.00µs
air::preparation_step::preparation::make_exec_ctx: 47.00µs
air_parser::parser::air_parser::parse: 78.00µs
runner::execute: 19.89ms
runner::farewell: 5.15ms
from_success_result: 5.13ms
populate_outcome_from_contexts: 5.02ms
signing_step::sign_produced_cids: 105.00µs
verification_step::verify: 80.00µs
verify: 12.00µs
call-results500 (15.60ms; 54.438 MiB, 54.438 MiB): multiple call results
air::runner::execute_air: 15.60ms
preparation_step::preparation::parse_data: 621.00µs
from_slice: 579.00µs
preparation_step::preparation::prepare: 1.00ms
air::preparation_step::preparation::make_exec_ctx: 803.00µs
air_parser::parser::air_parser::parse: 73.00µs
runner::execute: 11.60ms
runner::farewell: 1.80ms
from_success_result: 1.78ms
populate_outcome_from_contexts: 1.33ms
signing_step::sign_produced_cids: 290.00µs
verification_step::verify: 95.00µs
verify: 12.00µs
canon-map-key-by-lens (10.82ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 10.82ms
preparation_step::preparation::parse_data: 3.15ms
from_slice: 3.10ms
preparation_step::preparation::prepare: 385.00µs
air::preparation_step::preparation::make_exec_ctx: 187.00µs
air_parser::parser::air_parser::parse: 77.00µs
runner::execute: 1.96ms
runner::farewell: 1.87ms
from_success_result: 1.84ms
populate_outcome_from_contexts: 1.49ms
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 952.00µs
verify: 240.00µs
verification_step::verify: 3.18ms
verify: 2.82ms
canon-map-key-element-by-lens (10.75ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 10.75ms
preparation_step::preparation::parse_data: 3.13ms
from_slice: 3.08ms
preparation_step::preparation::prepare: 382.00µs
air::preparation_step::preparation::make_exec_ctx: 187.00µs
air_parser::parser::air_parser::parse: 77.00µs
runner::execute: 1.92ms
runner::farewell: 1.85ms
from_success_result: 1.83ms
populate_outcome_from_contexts: 1.49ms
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 3.17ms
verify: 2.81ms
canon-map-multiple-keys (8.96ms; 54.500 MiB, 54.500 MiB): benchmarking a map insert operation
air::runner::execute_air: 8.96ms
preparation_step::preparation::parse_data: 417.00µs
from_slice: 370.00µs
preparation_step::preparation::prepare: 201.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 66.00µs
runner::execute: 6.02ms
runner::farewell: 1.63ms
from_success_result: 1.61ms
populate_outcome_from_contexts: 1.32ms
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 403.00µs
verify: 40.00µs
canon-map-scalar-multiple-keys (4.08ms; 53.125 MiB, 53.125 MiB): benchmarking a map insert operation
air::runner::execute_air: 4.08ms
preparation_step::preparation::parse_data: 418.00µs
from_slice: 370.00µs
preparation_step::preparation::prepare: 197.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 62.00µs
runner::execute: 2.43ms
runner::farewell: 345.00µs
from_success_result: 325.00µs
populate_outcome_from_contexts: 289.00µs
signing_step::sign_produced_cids: 98.00µs
verification_step::verify: 405.00µs
verify: 40.00µs
canon-map-scalar-single-key (3.29ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 3.29ms
preparation_step::preparation::parse_data: 427.00µs
from_slice: 380.00µs
preparation_step::preparation::prepare: 200.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 62.00µs
runner::execute: 1.58ms
runner::farewell: 354.00µs
from_success_result: 334.00µs
populate_outcome_from_contexts: 282.00µs
signing_step::sign_produced_cids: 101.00µs
verification_step::verify: 437.00µs
verify: 75.00µs
canon-map-single-key (7.51ms; 55.312 MiB, 55.312 MiB): benchmarking a map insert operation
air::runner::execute_air: 7.51ms
preparation_step::preparation::parse_data: 426.00µs
from_slice: 378.00µs
preparation_step::preparation::prepare: 196.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 60.00µs
runner::execute: 4.45ms
runner::farewell: 1.73ms
from_success_result: 1.71ms
populate_outcome_from_contexts: 1.46ms
signing_step::sign_produced_cids: 99.00µs
verification_step::verify: 434.00µs
verify: 74.00µs
dashboard (5.70ms; 52.625 MiB, 52.625 MiB): big dashboard test
air::runner::execute_air: 5.70ms
preparation_step::preparation::parse_data: 1.02ms
from_slice: 960.00µs
preparation_step::preparation::prepare: 320.00µs
air::preparation_step::preparation::make_exec_ctx: 34.00µs
air_parser::parser::air_parser::parse: 167.00µs
runner::execute: 750.00µs
runner::farewell: 463.00µs
from_success_result: 443.00µs
populate_outcome_from_contexts: 402.00µs
signing_step::sign_produced_cids: 102.00µs
verification_step::verify: 2.87ms
verify: 158.00µs
long-data (4.96ms; 53.812 MiB, 53.812 MiB): Long data trace
air::runner::execute_air: 4.96ms
preparation_step::preparation::parse_data: 1.89ms
from_slice: 1.84ms
preparation_step::preparation::prepare: 183.00µs
air::preparation_step::preparation::make_exec_ctx: 35.00µs
air_parser::parser::air_parser::parse: 28.00µs
runner::execute: 12.00µs
runner::farewell: 888.00µs
from_success_result: 868.00µs
populate_outcome_from_contexts: 836.00µs
signing_step::sign_produced_cids: 99.00µs
verification_step::verify: 1.71ms
verify: 664.00µs
multiple-cids10 (2.54ms; 52.438 MiB, 52.438 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 2.54ms
preparation_step::preparation::parse_data: 434.00µs
from_slice: 381.00µs
preparation_step::preparation::prepare: 206.00µs
air::preparation_step::preparation::make_exec_ctx: 27.00µs
air_parser::parser::air_parser::parse: 61.00µs
runner::execute: 408.00µs
runner::farewell: 318.00µs
from_success_result: 298.00µs
populate_outcome_from_contexts: 251.00µs
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 896.00µs
verify: 182.00µs
multiple-cids50 (24.68ms; 59.375 MiB, 59.375 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 24.68ms
preparation_step::preparation::parse_data: 4.87ms
@ -855,21 +881,20 @@ Machine d77ebe8481884bc3b2778c8083f1bf459e548e929edd87041beb14f6b868d35f:
signing_step::sign_produced_cids: 109.00µs
verification_step::verify: 2.48ms
verify: 289.00µs
multiple-peers8 (9.96ms; 53.375 MiB, 53.375 MiB): verifying many CIDs for many peers
air::runner::execute_air: 9.96ms
preparation_step::preparation::parse_data: 1.36ms
multiple-peers8 (9.38ms; 53.375 MiB, 53.375 MiB): verifying many CIDs for many peers
air::runner::execute_air: 9.38ms
preparation_step::preparation::parse_data: 1.37ms
from_slice: 1.31ms
preparation_step::preparation::prepare: 254.00µs
air::preparation_step::preparation::make_exec_ctx: 70.00µs
air_parser::parser::air_parser::parse: 63.00µs
runner::execute: 2.87ms
to_string(tetraplets): 10.00µs
runner::farewell: 901.00µs
from_success_result: 881.00µs
preparation_step::preparation::prepare: 257.00µs
air::preparation_step::preparation::make_exec_ctx: 72.00µs
air_parser::parser::air_parser::parse: 68.00µs
runner::execute: 2.64ms
runner::farewell: 900.00µs
from_success_result: 880.00µs
populate_outcome_from_contexts: 783.00µs
signing_step::sign_produced_cids: 99.00µs
verification_step::verify: 3.97ms
verify: 1.02ms
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 3.94ms
verify: 743.00µs
multiple-sigs10 (13.63ms; 52.875 MiB, 52.875 MiB): signing multiple CIDs
air::runner::execute_air: 13.63ms
preparation_step::preparation::parse_data: 653.00µs
@ -904,20 +929,20 @@ Machine d77ebe8481884bc3b2778c8083f1bf459e548e929edd87041beb14f6b868d35f:
signing_step::sign_produced_cids: 22.05ms
verification_step::verify: 153.40ms
verify: 84.07ms
multiple-sigs30 (18.99ms; 56.188 MiB, 56.188 MiB): signing multiple CIDs
air::runner::execute_air: 18.99ms
preparation_step::preparation::parse_data: 3.94ms
from_slice: 3.88ms
preparation_step::preparation::prepare: 332.00µs
air::preparation_step::preparation::make_exec_ctx: 147.00µs
air_parser::parser::air_parser::parse: 62.00µs
runner::execute: 8.10ms
runner::farewell: 2.55ms
multiple-sigs30 (17.44ms; 56.188 MiB, 56.188 MiB): signing multiple CIDs
air::runner::execute_air: 17.44ms
preparation_step::preparation::parse_data: 3.91ms
from_slice: 3.85ms
preparation_step::preparation::prepare: 334.00µs
air::preparation_step::preparation::make_exec_ctx: 150.00µs
air_parser::parser::air_parser::parse: 66.00µs
runner::execute: 7.01ms
runner::farewell: 2.56ms
from_success_result: 2.54ms
populate_outcome_from_contexts: 2.36ms
signing_step::sign_produced_cids: 442.00µs
verification_step::verify: 2.99ms
verify: 1.30ms
populate_outcome_from_contexts: 2.37ms
signing_step::sign_produced_cids: 447.00µs
verification_step::verify: 2.98ms
verify: 1.27ms
multiple-sigs50 (49.64ms; 62.625 MiB, 62.625 MiB): signing multiple CIDs
air::runner::execute_air: 49.64ms
preparation_step::preparation::parse_data: 10.52ms
@ -932,21 +957,20 @@ Machine d77ebe8481884bc3b2778c8083f1bf459e548e929edd87041beb14f6b868d35f:
signing_step::sign_produced_cids: 1.23ms
verification_step::verify: 8.51ms
verify: 4.56ms
network-explore (3.13ms; 52.375 MiB, 52.375 MiB): 5 peers of network are discovered
air::runner::execute_air: 3.13ms
preparation_step::preparation::parse_data: 482.00µs
from_slice: 427.00µs
network-explore (3.08ms; 52.375 MiB, 52.375 MiB): 5 peers of network are discovered
air::runner::execute_air: 3.08ms
preparation_step::preparation::parse_data: 498.00µs
from_slice: 442.00µs
preparation_step::preparation::prepare: 220.00µs
air::preparation_step::preparation::make_exec_ctx: 19.00µs
air_parser::parser::air_parser::parse: 75.00µs
runner::execute: 167.00µs
to_string(tetraplets): 13.00µs
runner::farewell: 252.00µs
from_success_result: 232.00µs
populate_outcome_from_contexts: 195.00µs
signing_step::sign_produced_cids: 100.00µs
verification_step::verify: 1.72ms
verify: 80.00µs
air::preparation_step::preparation::make_exec_ctx: 21.00µs
air_parser::parser::air_parser::parse: 81.00µs
runner::execute: 139.00µs
runner::farewell: 253.00µs
from_success_result: 233.00µs
populate_outcome_from_contexts: 197.00µs
signing_step::sign_produced_cids: 104.00µs
verification_step::verify: 1.69ms
verify: 64.00µs
network_explore (5.23ms; 52.500 MiB, 52.500 MiB): 5 peers of network are discovered
air::runner::execute_air: 5.23ms
preparation_step::preparation::parse_data: 480.00µs
@ -994,98 +1018,208 @@ Machine d77ebe8481884bc3b2778c8083f1bf459e548e929edd87041beb14f6b868d35f:
signing_step::sign_produced_cids: 104.00µs
verification_step::verify: 44.00µs
verify: 12.00µs
populate-map-multiple-keys (3.42ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 3.42ms
preparation_step::preparation::parse_data: 151.00µs
from_slice: 107.00µs
preparation_step::preparation::prepare: 197.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 60.00µs
runner::execute: 2.12ms
runner::farewell: 289.00µs
from_success_result: 269.00µs
populate_outcome_from_contexts: 233.00µs
signing_step::sign_produced_cids: 96.00µs
verification_step::verify: 392.00µs
verify: 48.00µs
populate-map-single-key (2.71ms; 52.938 MiB, 52.938 MiB): benchmarking a map insert operation
air::runner::execute_air: 2.71ms
preparation_step::preparation::parse_data: 207.00µs
from_slice: 163.00µs
preparation_step::preparation::prepare: 194.00µs
air::preparation_step::preparation::make_exec_ctx: 15.00µs
air_parser::parser::air_parser::parse: 58.00µs
runner::execute: 1.29ms
populate-map-multiple-keys (3.44ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 3.44ms
preparation_step::preparation::parse_data: 167.00µs
from_slice: 120.00µs
preparation_step::preparation::prepare: 201.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 65.00µs
runner::execute: 2.10ms
runner::farewell: 291.00µs
from_success_result: 271.00µs
populate_outcome_from_contexts: 235.00µs
signing_step::sign_produced_cids: 98.00µs
verification_step::verify: 394.00µs
verify: 41.00µs
populate-map-single-key (2.74ms; 52.938 MiB, 52.938 MiB): benchmarking a map insert operation
air::runner::execute_air: 2.74ms
preparation_step::preparation::parse_data: 223.00µs
from_slice: 176.00µs
preparation_step::preparation::prepare: 198.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 63.00µs
runner::execute: 1.30ms
runner::farewell: 311.00µs
from_success_result: 290.00µs
populate_outcome_from_contexts: 236.00µs
signing_step::sign_produced_cids: 95.00µs
verification_step::verify: 435.00µs
verify: 93.00µs
populate_outcome_from_contexts: 235.00µs
signing_step::sign_produced_cids: 99.00µs
verification_step::verify: 426.00µs
verify: 75.00µs
Machine e536f8eaae8c978493a773ba566ae3393e2e6240d6ea8e05b5ca1b8f77e9c441:
Platform: Linux-5.15.0-76-generic-x86_64-with-glibc2.29
Timestamp: 2023-10-20 12:46:01.094988+00:00
AquaVM version: 0.53.0
Timestamp: 2023-11-27 15:10:46.006416+00:00
AquaVM version: 0.54.0
Benches:
Features: check_signatures,gen_signatures
big_values_data (12.11ms; 58.938 MiB, 58.938 MiB): Loading a trace with huge values
air::runner::execute_air: 12.11ms
preparation_step::preparation::parse_data: 6.80ms
from_slice: 6.74ms
preparation_step::preparation::prepare: 226.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 19.00µs
big-values-data (17.72ms; 59.000 MiB, 59.000 MiB): Loading a trace with huge values
air::runner::execute_air: 17.72ms
preparation_step::preparation::parse_data: 7.12ms
from_slice: 7.06ms
preparation_step::preparation::prepare: 224.00µs
air::preparation_step::preparation::make_exec_ctx: 22.00µs
air_parser::parser::air_parser::parse: 20.00µs
runner::execute: 10.00µs
runner::farewell: 4.70ms
from_success_result: 4.68ms
populate_outcome_from_contexts: 4.62ms
runner::farewell: 4.72ms
from_success_result: 4.70ms
populate_outcome_from_contexts: 4.64ms
signing_step::sign_produced_cids: 162.00µs
verification_step::verify: 5.34ms
verify: 4.80ms
call-requests500 (35.01ms; 58.562 MiB, 58.562 MiB): multiple call requests
air::runner::execute_air: 35.01ms
preparation_step::preparation::parse_data: 116.00µs
from_slice: 78.00µs
preparation_step::preparation::prepare: 273.00µs
air::preparation_step::preparation::make_exec_ctx: 39.00µs
air_parser::parser::air_parser::parse: 49.00µs
runner::execute: 24.69ms
runner::farewell: 9.56ms
from_success_result: 9.54ms
populate_outcome_from_contexts: 9.38ms
signing_step::sign_produced_cids: 164.00µs
verification_step::verify: 77.00µs
verify: 10.00µs
call-results500 (19.19ms; 54.438 MiB, 54.438 MiB): multiple call results
air::runner::execute_air: 19.19ms
preparation_step::preparation::parse_data: 657.00µs
from_slice: 618.00µs
preparation_step::preparation::prepare: 925.00µs
air::preparation_step::preparation::make_exec_ctx: 688.00µs
air_parser::parser::air_parser::parse: 50.00µs
runner::execute: 14.78ms
runner::farewell: 2.17ms
from_success_result: 2.15ms
populate_outcome_from_contexts: 1.77ms
signing_step::sign_produced_cids: 435.00µs
verification_step::verify: 81.00µs
verify: 10.00µs
canon-map-key-by-lens (14.88ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 14.88ms
preparation_step::preparation::parse_data: 4.04ms
from_slice: 3.99ms
preparation_step::preparation::prepare: 530.00µs
air::preparation_step::preparation::make_exec_ctx: 288.00µs
air_parser::parser::air_parser::parse: 57.00µs
runner::execute: 2.76ms
runner::farewell: 2.78ms
from_success_result: 2.75ms
populate_outcome_from_contexts: 2.40ms
signing_step::sign_produced_cids: 159.00µs
verification_step::verify: 86.00µs
verify: 11.00µs
dashboard (9.52ms; 52.625 MiB, 52.625 MiB): big dashboard test
air::runner::execute_air: 9.52ms
preparation_step::preparation::parse_data: 1.26ms
from_slice: 1.21ms
preparation_step::preparation::prepare: 354.00µs
air::preparation_step::preparation::make_exec_ctx: 42.00µs
air_parser::parser::air_parser::parse: 135.00µs
runner::execute: 2.27ms
to_string(tetraplets): 449.00µs
runner::farewell: 672.00µs
from_success_result: 651.00µs
populate_outcome_from_contexts: 601.00µs
verification_step::verify: 4.48ms
verify: 3.95ms
canon-map-key-element-by-lens (14.80ms; 56.625 MiB, 56.625 MiB): benchmarking a map insert operation
air::runner::execute_air: 14.80ms
preparation_step::preparation::parse_data: 4.03ms
from_slice: 3.99ms
preparation_step::preparation::prepare: 535.00µs
air::preparation_step::preparation::make_exec_ctx: 293.00µs
air_parser::parser::air_parser::parse: 59.00µs
runner::execute: 2.69ms
runner::farewell: 2.76ms
from_success_result: 2.74ms
populate_outcome_from_contexts: 2.40ms
signing_step::sign_produced_cids: 159.00µs
verification_step::verify: 4.48ms
verify: 3.96ms
canon-map-multiple-keys (12.47ms; 54.500 MiB, 54.500 MiB): benchmarking a map insert operation
air::runner::execute_air: 12.47ms
preparation_step::preparation::parse_data: 357.00µs
from_slice: 317.00µs
preparation_step::preparation::prepare: 248.00µs
air::preparation_step::preparation::make_exec_ctx: 19.00µs
air_parser::parser::air_parser::parse: 47.00µs
runner::execute: 8.71ms
runner::farewell: 2.31ms
from_success_result: 2.29ms
populate_outcome_from_contexts: 2.00ms
signing_step::sign_produced_cids: 161.00µs
verification_step::verify: 4.57ms
verify: 267.00µs
long_data (4.57ms; 53.750 MiB, 53.750 MiB): Long data trace
air::runner::execute_air: 4.57ms
preparation_step::preparation::parse_data: 2.27ms
from_slice: 2.23ms
preparation_step::preparation::prepare: 216.00µs
air::preparation_step::preparation::make_exec_ctx: 16.00µs
verification_step::verify: 554.00µs
verify: 28.00µs
canon-map-scalar-multiple-keys (5.18ms; 53.125 MiB, 53.125 MiB): benchmarking a map insert operation
air::runner::execute_air: 5.18ms
preparation_step::preparation::parse_data: 359.00µs
from_slice: 319.00µs
preparation_step::preparation::prepare: 243.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 46.00µs
runner::execute: 3.28ms
runner::farewell: 462.00µs
from_success_result: 440.00µs
populate_outcome_from_contexts: 397.00µs
signing_step::sign_produced_cids: 159.00µs
verification_step::verify: 554.00µs
verify: 28.00µs
canon-map-scalar-single-key (4.27ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 4.27ms
preparation_step::preparation::parse_data: 382.00µs
from_slice: 342.00µs
preparation_step::preparation::prepare: 241.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 43.00µs
runner::execute: 2.31ms
runner::farewell: 454.00µs
from_success_result: 432.00µs
populate_outcome_from_contexts: 379.00µs
signing_step::sign_produced_cids: 160.00µs
verification_step::verify: 588.00µs
verify: 61.00µs
canon-map-single-key (10.90ms; 55.312 MiB, 55.312 MiB): benchmarking a map insert operation
air::runner::execute_air: 10.90ms
preparation_step::preparation::parse_data: 381.00µs
from_slice: 340.00µs
preparation_step::preparation::prepare: 244.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 44.00µs
runner::execute: 6.73ms
runner::farewell: 2.64ms
from_success_result: 2.62ms
populate_outcome_from_contexts: 2.36ms
signing_step::sign_produced_cids: 168.00µs
verification_step::verify: 596.00µs
verify: 62.00µs
dashboard (8.22ms; 52.625 MiB, 52.625 MiB): big dashboard test
air::runner::execute_air: 8.22ms
preparation_step::preparation::parse_data: 1.28ms
from_slice: 1.23ms
preparation_step::preparation::prepare: 350.00µs
air::preparation_step::preparation::make_exec_ctx: 41.00µs
air_parser::parser::air_parser::parse: 131.00µs
runner::execute: 1.08ms
runner::farewell: 656.00µs
from_success_result: 634.00µs
populate_outcome_from_contexts: 584.00µs
signing_step::sign_produced_cids: 162.00µs
verification_step::verify: 4.55ms
verify: 195.00µs
long-data (6.32ms; 53.812 MiB, 53.812 MiB): Long data trace
air::runner::execute_air: 6.32ms
preparation_step::preparation::parse_data: 2.39ms
from_slice: 2.35ms
preparation_step::preparation::prepare: 238.00µs
air::preparation_step::preparation::make_exec_ctx: 41.00µs
air_parser::parser::air_parser::parse: 18.00µs
runner::execute: 9.00µs
runner::farewell: 1.13ms
from_success_result: 1.14ms
populate_outcome_from_contexts: 1.10ms
signing_step::sign_produced_cids: 157.00µs
verification_step::verify: 662.00µs
verify: 11.00µs
multiple-cids10 (3.53ms; 52.438 MiB, 52.438 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 3.53ms
runner::farewell: 1.07ms
from_success_result: 1.05ms
populate_outcome_from_contexts: 1.01ms
signing_step::sign_produced_cids: 158.00µs
verification_step::verify: 2.33ms
verify: 841.00µs
multiple-cids10 (3.37ms; 52.438 MiB, 52.438 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 3.37ms
preparation_step::preparation::parse_data: 467.00µs
from_slice: 413.00µs
preparation_step::preparation::prepare: 263.00µs
air::preparation_step::preparation::make_exec_ctx: 34.00µs
air_parser::parser::air_parser::parse: 47.00µs
runner::execute: 593.00µs
to_string(tetraplets): 14.00µs
runner::farewell: 470.00µs
from_success_result: 448.00µs
populate_outcome_from_contexts: 392.00µs
signing_step::sign_produced_cids: 161.00µs
verification_step::verify: 1.45ms
verify: 317.00µs
from_slice: 414.00µs
preparation_step::preparation::prepare: 256.00µs
air::preparation_step::preparation::make_exec_ctx: 32.00µs
air_parser::parser::air_parser::parse: 44.00µs
runner::execute: 568.00µs
runner::farewell: 456.00µs
from_success_result: 434.00µs
populate_outcome_from_contexts: 375.00µs
signing_step::sign_produced_cids: 159.00µs
verification_step::verify: 1.34ms
verify: 230.00µs
multiple-cids50 (323.00ms; 59.375 MiB, 59.375 MiB): verifying multiple CIDs for single peer
air::runner::execute_air: 323.00ms
preparation_step::preparation::parse_data: 6.79ms
@ -1149,21 +1283,20 @@ Machine e536f8eaae8c978493a773ba566ae3393e2e6240d6ea8e05b5ca1b8f77e9c441:
signing_step::sign_produced_cids: 190.00µs
verification_step::verify: 70.22ms
verify: 44.09ms
multiple-peers8 (14.36ms; 53.375 MiB, 53.375 MiB): verifying many CIDs for many peers
air::runner::execute_air: 14.36ms
multiple-peers8 (13.47ms; 53.375 MiB, 53.375 MiB): verifying many CIDs for many peers
air::runner::execute_air: 13.47ms
preparation_step::preparation::parse_data: 1.74ms
from_slice: 1.68ms
preparation_step::preparation::prepare: 333.00µs
air::preparation_step::preparation::make_exec_ctx: 102.00µs
air_parser::parser::air_parser::parse: 50.00µs
runner::execute: 3.62ms
to_string(tetraplets): 16.00µs
preparation_step::preparation::prepare: 334.00µs
air::preparation_step::preparation::make_exec_ctx: 103.00µs
air_parser::parser::air_parser::parse: 51.00µs
runner::execute: 3.63ms
runner::farewell: 1.30ms
from_success_result: 1.31ms
populate_outcome_from_contexts: 1.16ms
signing_step::sign_produced_cids: 161.00µs
verification_step::verify: 6.74ms
verify: 1.45ms
from_success_result: 1.28ms
populate_outcome_from_contexts: 1.17ms
signing_step::sign_produced_cids: 159.00µs
verification_step::verify: 6.18ms
verify: 1.03ms
multiple-sigs200 (6.04s; 214.375 MiB, 214.375 MiB): signing multiple CIDs
air::runner::execute_air: 6.04s
preparation_step::preparation::parse_data: 219.80ms
@ -1184,20 +1317,20 @@ Machine e536f8eaae8c978493a773ba566ae3393e2e6240d6ea8e05b5ca1b8f77e9c441:
signing_step::sign_produced_cids: 30.84ms
verification_step::verify: 214.00ms
verify: 119.20ms
multiple-sigs30 (26.89ms; 56.188 MiB, 56.188 MiB): signing multiple CIDs
air::runner::execute_air: 26.89ms
preparation_step::preparation::parse_data: 5.04ms
from_slice: 4.99ms
preparation_step::preparation::prepare: 454.00µs
air::preparation_step::preparation::make_exec_ctx: 219.00µs
air_parser::parser::air_parser::parse: 50.00µs
runner::execute: 11.80ms
runner::farewell: 3.74ms
from_success_result: 3.71ms
populate_outcome_from_contexts: 3.54ms
signing_step::sign_produced_cids: 678.00µs
verification_step::verify: 5.03ms
verify: 2.50ms
multiple-sigs30 (24.67ms; 56.188 MiB, 56.188 MiB): signing multiple CIDs
air::runner::execute_air: 24.67ms
preparation_step::preparation::parse_data: 4.93ms
from_slice: 4.87ms
preparation_step::preparation::prepare: 446.00µs
air::preparation_step::preparation::make_exec_ctx: 215.00µs
air_parser::parser::air_parser::parse: 49.00µs
runner::execute: 10.49ms
runner::farewell: 3.70ms
from_success_result: 3.68ms
populate_outcome_from_contexts: 3.50ms
signing_step::sign_produced_cids: 668.00µs
verification_step::verify: 4.30ms
verify: 1.81ms
multiple-sigs50 (369.10ms; 62.562 MiB, 62.562 MiB): signing multiple CIDs
air::runner::execute_air: 369.10ms
preparation_step::preparation::parse_data: 13.94ms
@ -1218,21 +1351,20 @@ Machine e536f8eaae8c978493a773ba566ae3393e2e6240d6ea8e05b5ca1b8f77e9c441:
signing_step::sign_produced_cids: 1.77ms
verification_step::verify: 12.49ms
verify: 6.96ms
network-explore (4.43ms; 52.375 MiB, 52.375 MiB): 5 peers of network are discovered
air::runner::execute_air: 4.43ms
preparation_step::preparation::parse_data: 572.00µs
from_slice: 519.00µs
preparation_step::preparation::prepare: 268.00µs
air::preparation_step::preparation::make_exec_ctx: 23.00µs
network-explore (4.35ms; 52.375 MiB, 52.375 MiB): 5 peers of network are discovered
air::runner::execute_air: 4.35ms
preparation_step::preparation::parse_data: 582.00µs
from_slice: 525.00µs
preparation_step::preparation::prepare: 267.00µs
air::preparation_step::preparation::make_exec_ctx: 22.00µs
air_parser::parser::air_parser::parse: 67.00µs
runner::execute: 190.00µs
to_string(tetraplets): 13.00µs
runner::farewell: 366.00µs
from_success_result: 344.00µs
populate_outcome_from_contexts: 301.00µs
signing_step::sign_produced_cids: 162.00µs
verification_step::verify: 2.75ms
verify: 79.00µs
runner::execute: 163.00µs
runner::farewell: 363.00µs
from_success_result: 342.00µs
populate_outcome_from_contexts: 298.00µs
signing_step::sign_produced_cids: 160.00µs
verification_step::verify: 2.69ms
verify: 64.00µs
null (848.00µs; 52.375 MiB, 52.375 MiB): Empty data and null script
air::runner::execute_air: 848.00µs
preparation_step::preparation::parse_data: 18.00µs
@ -1259,3 +1391,31 @@ Machine e536f8eaae8c978493a773ba566ae3393e2e6240d6ea8e05b5ca1b8f77e9c441:
signing_step::sign_produced_cids: 160.00µs
verification_step::verify: 36.00µs
verify: 11.00µs
populate-map-multiple-keys (4.37ms; 53.000 MiB, 53.000 MiB): benchmarking a map insert operation
air::runner::execute_air: 4.37ms
preparation_step::preparation::parse_data: 130.00µs
from_slice: 91.00µs
preparation_step::preparation::prepare: 246.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 49.00µs
runner::execute: 2.77ms
runner::farewell: 387.00µs
from_success_result: 365.00µs
populate_outcome_from_contexts: 325.00µs
signing_step::sign_produced_cids: 158.00µs
verification_step::verify: 549.00µs
verify: 27.00µs
populate-map-single-key (3.62ms; 52.938 MiB, 52.938 MiB): benchmarking a map insert operation
air::runner::execute_air: 3.62ms
preparation_step::preparation::parse_data: 199.00µs
from_slice: 159.00µs
preparation_step::preparation::prepare: 243.00µs
air::preparation_step::preparation::make_exec_ctx: 18.00µs
air_parser::parser::air_parser::parse: 46.00µs
runner::execute: 1.91ms
runner::farewell: 400.00µs
from_success_result: 377.00µs
populate_outcome_from_contexts: 324.00µs
signing_step::sign_produced_cids: 160.00µs
verification_step::verify: 586.00µs
verify: 61.00µs

View File

@ -9,6 +9,7 @@ edition = "2021"
aquavm-air = { path = "../../air", features = ["gen_signatures", "check_signatures"] }
air-interpreter-cid = { path = "../../crates/air-lib/interpreter-cid" }
air-interpreter-data = { path = "../../crates/air-lib/interpreter-data" }
air-interpreter-interface = { path = "../../crates/air-lib/interpreter-interface" }
air-interpreter-signatures = { path = "../../crates/air-lib/interpreter-signatures" }
air-test-utils = { path = "../../crates/air-lib/test-utils" }
air-testing-framework = { path = "../../crates/testing-framework" }

View File

@ -21,7 +21,10 @@ for bench in multiple-cids10 \
network-explore \
long-data \
populate-map-multiple-keys \
populate-map-single-key ;
populate-map-single-key \
call-requests500 \
call-results500 \
;
do
echo "Generating ${bench} ..." >&2
DESTDIR="../../benches/performance_metering/${bench}/"

View File

@ -0,0 +1,136 @@
use crate::Data;
use air_test_utils::key_utils::derive_dummy_keypair;
use air_test_utils::prelude::*;
use maplit::hashmap;
static AIR_SCRIPT: &str = r#"
(seq
(call %init_peer_id% ("init" "init") [] data)
(fold data i
(par
(call %init_peer_id% ("handle" "handle") [i i i i i i i i i i i i i i i i i i i i i i i i] $stream)
(next i))))
"#;
pub(crate) fn call_requests(size: usize) -> Data {
let values: Vec<_> = (0..size).map(|n| format!("{n}")).collect();
let data = json!(values);
let init_peer_name = "peer_id";
let particle_id = "particle_id";
let (init_peer_keypair, init_peer_id) = derive_dummy_keypair(init_peer_name);
let mut avm = create_avm_with_key::<NativeAirRunner>(
init_peer_keypair.clone(),
// actually, is not used
set_variable_call_service(data.clone()),
);
let init_call_results: CallResults = <_>::default();
let res_init = avm
.call_single(
AIR_SCRIPT,
"",
"",
init_peer_id.clone(),
0,
0,
None,
init_call_results,
particle_id,
)
.unwrap();
// initialization call requests
let call_results: CallResults = res_init
.call_requests
.keys()
.map(|id| (*id, CallServiceResult::ok(data.clone())))
.collect();
Data {
air: AIR_SCRIPT.to_owned(),
prev_data: res_init.data,
cur_data: vec![],
params_json: hashmap! {
"comment".to_owned() => "multiple call requests".to_owned(),
"particle-id".to_owned() => particle_id.to_owned(),
"current-peer-id".to_owned() => init_peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
},
call_results: Some(call_results),
keypair: bs58::encode(init_peer_keypair.as_inner().to_vec()).into_string(),
}
}
pub(crate) fn call_results(size: usize) -> Data {
let values: Vec<_> = (0..size).map(|n| format!("{n}")).collect();
let data = json!(values);
let init_peer_name = "peer_id";
let particle_id = "particle_id";
let (init_peer_keypair, init_peer_id) = derive_dummy_keypair(init_peer_name);
let mut avm = create_avm_with_key::<NativeAirRunner>(
init_peer_keypair.clone(),
// actually, is not used
set_variable_call_service(data.clone()),
);
let call_results: CallResults = <_>::default();
let res_init = avm
.call_single(
AIR_SCRIPT,
"",
"",
init_peer_id.clone(),
0,
0,
None,
call_results,
particle_id,
)
.unwrap();
// initialization call requests
let init_call_results: CallResults = res_init
.call_requests
.keys()
.map(|id| (*id, CallServiceResult::ok(data.clone())))
.collect();
let res = avm
.call_single(
AIR_SCRIPT,
res_init.data,
"",
init_peer_id.clone(),
0,
0,
None,
init_call_results,
particle_id,
)
.unwrap();
let call_results: CallResults = res
.call_requests
.iter()
.map(|(id, req)| (*id, CallServiceResult::ok(req.arguments.clone().into())))
.collect();
Data {
air: AIR_SCRIPT.to_owned(),
prev_data: res.data,
cur_data: vec![],
params_json: hashmap! {
"comment".to_owned() => "multiple call results".to_owned(),
"particle-id".to_owned() => particle_id.to_owned(),
"current-peer-id".to_owned() => init_peer_id.clone(),
"init-peer-id".to_owned() => init_peer_id,
},
call_results: Some(call_results),
keypair: bs58::encode(init_peer_keypair.as_inner().to_vec()).into_string(),
}
}

View File

@ -14,6 +14,7 @@ use std::path::PathBuf;
const PARTICLE_ID: &str = "0123456789ABCDEF";
const MAX_STREAM_SIZE: usize = 1023;
mod calls;
mod cid_benchmarking;
mod dashboard;
mod data;
@ -50,6 +51,8 @@ enum Bench {
CanonMapScalarSingleKey,
LongData,
BigValuesData,
CallRequests500,
CallResults500,
}
fn main() {
@ -76,6 +79,8 @@ fn main() {
Bench::CanonMapKeyElementByLens => canon_map_key_element_by_lens(770),
Bench::LongData => long_data(),
Bench::BigValuesData => big_values_data(),
Bench::CallRequests500 => calls::call_requests(500),
Bench::CallResults500 => calls::call_results(500),
};
save_data(&args.dest_dir, data).unwrap();
@ -86,31 +91,42 @@ fn save_data(dest_dir: &Path, data: Data) -> Result<(), Box<dyn std::error::Erro
create_dir_all(dest_dir)?;
save_file(dest_dir, "script.air", Some(&data.air))?;
save_file(dest_dir, "script.air", &data.air)?;
save_file(
dest_dir,
"prev_data.json",
reformat_json_if_possible(&data.prev_data),
&reformat_json_if_possible(&data.prev_data),
)?;
save_file(
dest_dir,
"cur_data.json",
reformat_json_if_possible(&data.cur_data),
&reformat_json_if_possible(&data.cur_data),
)?;
save_file(
dest_dir,
"params.json",
Some(&serde_json::to_vec_pretty(&data.params_json)?),
&serde_json::to_vec_pretty(&data.params_json)?,
)?;
save_file(dest_dir, "keypair.ed25519", Some(&data.keypair))?;
save_file(dest_dir, "keypair.ed25519", &data.keypair)?;
if let Some(call_results) = data.call_results {
save_file(
dest_dir,
"call_results.json",
// these call results are intended for manual generation too for the AIR CLI, so
// simplier representation from avm_interface::CallResults is used, and JSON is used explicitely
&reformat_json_if_possible(&serde_json::to_vec(&call_results).unwrap()),
)
.unwrap();
}
Ok(())
}
/// make zero-indentation data for better git diffs
fn reformat_json_if_possible(data: &[u8]) -> Option<Vec<u8>> {
fn reformat_json_if_possible(data: &[u8]) -> Vec<u8> {
if data.is_empty() {
return None;
return data.into();
}
let obj: serde_json::Value = serde_json::from_slice(data).unwrap();
@ -118,26 +134,18 @@ fn reformat_json_if_possible(data: &[u8]) -> Option<Vec<u8>> {
let mut out = vec![];
let mut ser = serde_json::ser::Serializer::with_formatter(&mut out, fmt);
obj.serialize(&mut ser).unwrap();
Some(out)
out
}
fn save_file(
dest_dir: &Path,
filename: &str,
data: Option<impl AsRef<[u8]>>,
data: impl AsRef<[u8]>,
) -> Result<(), Box<dyn std::error::Error>> {
use std::fs::*;
use std::io::prelude::*;
let mut dest_dir = dest_dir.to_owned();
dest_dir.push(filename);
let mut f = File::create(&dest_dir)?;
if let Some(data) = data {
f.write_all(data.as_ref())?;
}
Ok(())
Ok(std::fs::write(dest_dir, data)?)
}
#[derive(Debug, Default)]
@ -147,7 +155,7 @@ pub(crate) struct Data {
pub(crate) prev_data: Vec<u8>,
pub(crate) cur_data: Vec<u8>,
pub(crate) params_json: HashMap<String, String>,
pub(crate) call_results: Option<serde_json::Value>,
pub(crate) call_results: Option<CallResults>,
pub(crate) keypair: String,
}

View File

@ -274,6 +274,8 @@ fn read_call_results(call_results_path: Option<&Path>) -> anyhow::Result<CallRes
Some(call_results_path) => {
let call_results_json =
load_data(call_results_path).context("failed to read call_results")?;
// call resuls are may be manually crafted, so JSON representation
// of avm_interface::CallResults is more user-friendly
Ok(serde_json::from_str(&call_results_json)
.context("failed to parse call_results data")?)
}

View File

@ -62,6 +62,10 @@ class Bench:
self.cur_data_path = discover_file(bench_path, "cur_data.json")
self.air_script_path = discover_file(bench_path, "script.air")
self.keypair = discover_file(bench_path, "keypair.ed25519")
try:
self.call_results = discover_file(bench_path, "call_results.json")
except IOError:
self.call_results = None
self.native = native
def run(self, repeat, tracing_params):
@ -85,6 +89,9 @@ class Bench:
"--ed25519-key", self.keypair,
] + (
["--native"] if self.native else []
) + (
["--call-results", self.call_results] if self.call_results
else []
) + [
"--tracing-params", tracing_params,
"--plain",