From 775bb81d351583054403876e1039c5ed814d49c4 Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 3 Oct 2024 11:44:02 -0700 Subject: [PATCH] testing/gas profiling for it --- .../aptos-gas-calibration/src/measurements.rs | 20 +-- .../src/measurements_helpers.rs | 20 +-- aptos-move/aptos-vm-benchmarks/src/helper.rs | 20 +-- aptos-move/e2e-benchmark/src/main.rs | 124 ++++++++++++++---- aptos-move/e2e-tests/src/executor.rs | 31 ++++- .../framework/aptos-stdlib/doc/big_vector.md | 2 +- crates/transaction-generator-lib/src/args.rs | 18 +++ .../src/publishing/module_simple.rs | 73 +++++++++++ .../src/publishing/raw_module_data.rs | 85 +++++++++--- .../sources/vector_example.move | 47 +++++++ testsuite/single_node_performance.py | 5 +- 11 files changed, 373 insertions(+), 72 deletions(-) create mode 100644 testsuite/module-publish/src/packages/framework_usecases/sources/vector_example.move diff --git a/aptos-move/aptos-gas-calibration/src/measurements.rs b/aptos-move/aptos-gas-calibration/src/measurements.rs index fa0257ce29a0c..92b8688b141cb 100644 --- a/aptos-move/aptos-gas-calibration/src/measurements.rs +++ b/aptos-move/aptos-gas-calibration/src/measurements.rs @@ -162,15 +162,17 @@ fn compile_and_run_samples_ir( .equation_names .push(format!("{}::{}", &identifier, func_identifier.0)); - let elapsed = executor.exec_func_record_running_time( - &module_id, - &func_identifier.0, - vec![], - func_identifier.1.clone(), - iterations, - ExecFuncTimerDynamicArgs::NoArgs, - GasMeterType::UnmeteredGasMeter, - ); + let elapsed = executor + .exec_func_record_running_time( + &module_id, + &func_identifier.0, + vec![], + func_identifier.1.clone(), + iterations, + ExecFuncTimerDynamicArgs::NoArgs, + GasMeterType::UnmeteredGasMeter, + ) + .elapsed_micros; gas_measurement.regular_meter.push(elapsed); // record with abstract gas meter diff --git a/aptos-move/aptos-gas-calibration/src/measurements_helpers.rs b/aptos-move/aptos-gas-calibration/src/measurements_helpers.rs index 3f242b4457d4e..cfcc0952696a2 100644 --- a/aptos-move/aptos-gas-calibration/src/measurements_helpers.rs +++ b/aptos-move/aptos-gas-calibration/src/measurements_helpers.rs @@ -94,15 +94,17 @@ pub fn execute_user_txn( iterations: u64, args: Vec>, ) -> u128 { - let elapsed = executor.exec_func_record_running_time( - module_name, - function_name, - vec![], - args, - iterations, - ExecFuncTimerDynamicArgs::NoArgs, - GasMeterType::UnmeteredGasMeter, - ); + let elapsed = executor + .exec_func_record_running_time( + module_name, + function_name, + vec![], + args, + iterations, + ExecFuncTimerDynamicArgs::NoArgs, + GasMeterType::UnmeteredGasMeter, + ) + .elapsed_micros; println!("running time (microseconds): {}", elapsed); elapsed } diff --git a/aptos-move/aptos-vm-benchmarks/src/helper.rs b/aptos-move/aptos-vm-benchmarks/src/helper.rs index aea964f3e20e2..25d12122a61a5 100644 --- a/aptos-move/aptos-vm-benchmarks/src/helper.rs +++ b/aptos-move/aptos-vm-benchmarks/src/helper.rs @@ -64,15 +64,17 @@ pub fn execute_module_txn( // sign user transaction and only records the body of the transaction pub fn execute_user_txn(executor: &mut FakeExecutor, module_name: &ModuleId, function_name: &str) { - let elapsed = executor.exec_func_record_running_time( - module_name, - function_name, - vec![], - vec![], - 10, - ExecFuncTimerDynamicArgs::NoArgs, - GasMeterType::UnmeteredGasMeter, - ); + let elapsed = executor + .exec_func_record_running_time( + module_name, + function_name, + vec![], + vec![], + 10, + ExecFuncTimerDynamicArgs::NoArgs, + GasMeterType::UnmeteredGasMeter, + ) + .elapsed_micros; println!("running time (microseconds): {}", elapsed); } diff --git a/aptos-move/e2e-benchmark/src/main.rs b/aptos-move/e2e-benchmark/src/main.rs index a00e511eaea89..a83537675e65d 100644 --- a/aptos-move/e2e-benchmark/src/main.rs +++ b/aptos-move/e2e-benchmark/src/main.rs @@ -3,7 +3,7 @@ use aptos_language_e2e_tests::{ account::Account, - executor::{ExecFuncTimerDynamicArgs, FakeExecutor, GasMeterType}, + executor::{ExecFuncTimerDynamicArgs, FakeExecutor, GasMeterType, TimeAndGas}, }; use aptos_transaction_generator_lib::{ publishing::{ @@ -46,7 +46,7 @@ fn execute_and_time_entry_point( publisher_address: &AccountAddress, executor: &mut FakeExecutor, iterations: u64, -) -> u128 { +) -> TimeAndGas { let mut rng = StdRng::seed_from_u64(14); let entry_fun = entry_point .create_payload( @@ -100,7 +100,7 @@ fn main() { loop_type: LoopType::Arithmetic, }), // This is a cheap bcs (serializing vec), so not representative of what BCS native call should cost. - // (, EntryPoints::Loop { loop_count: Some(1000), loop_type: LoopType::BCS { len: 1024 }}), + // (, EntryPoints::Loop { loop_count: Some(1000), loop_type: LoopType::BcsToBytes { len: 1024 }}), (125, EntryPoints::CreateObjects { num_objects: 10, object_payload_size: 0, @@ -117,9 +117,9 @@ fn main() { num_objects: 100, object_payload_size: 10 * 1024, }), - (65, EntryPoints::InitializeVectorPicture { length: 40 }), - (14, EntryPoints::VectorPicture { length: 40 }), - (14, EntryPoints::VectorPictureRead { length: 40 }), + (160, EntryPoints::InitializeVectorPicture { length: 128 }), + (34, EntryPoints::VectorPicture { length: 128 }), + (34, EntryPoints::VectorPictureRead { length: 128 }), (29000, EntryPoints::InitializeVectorPicture { length: 30 * 1024, }), @@ -144,14 +144,83 @@ fn main() { (401, EntryPoints::TokenV2AmbassadorMint { numbered: true }), (467, EntryPoints::LiquidityPoolSwap { is_stable: true }), (415, EntryPoints::LiquidityPoolSwap { is_stable: false }), + (146, EntryPoints::CoinInitAndMint), + (154, EntryPoints::FungibleAssetMint), + (23, EntryPoints::IncGlobalMilestoneAggV2 { + milestone_every: 1, + }), + (12, EntryPoints::IncGlobalMilestoneAggV2 { + milestone_every: 2, + }), + (6871, EntryPoints::EmitEvents { count: 1000 }), + // long vectors with small elements + (15890, EntryPoints::VectorSplitOffAppend { + // baseline, only vector creation + vec_len: 3000, + element_len: 1, + index: 0, + repeats: 0, + }), + (38047, EntryPoints::VectorSplitOffAppend { + vec_len: 3000, + element_len: 1, + index: 100, + repeats: 1000, + }), + (25923, EntryPoints::VectorSplitOffAppend { + vec_len: 3000, + element_len: 1, + index: 2990, + repeats: 1000, + }), + (35590, EntryPoints::VectorRemoveInsert { + vec_len: 3000, + element_len: 1, + index: 100, + repeats: 1000, + }), + (28141, EntryPoints::VectorRemoveInsert { + vec_len: 3000, + element_len: 1, + index: 2998, + repeats: 1000, + }), + (53500, EntryPoints::VectorRangeMove { + vec_len: 3000, + element_len: 1, + index: 1000, + move_len: 500, + repeats: 1000, + }), + // vectors with large elements + (654, EntryPoints::VectorSplitOffAppend { + // baseline, only vector creation + vec_len: 100, + element_len: 100, + index: 0, + repeats: 0, + }), + (11147, EntryPoints::VectorSplitOffAppend { + vec_len: 100, + element_len: 100, + index: 10, + repeats: 1000, + }), + (5545, EntryPoints::VectorRangeMove { + vec_len: 100, + element_len: 100, + index: 50, + move_len: 10, + repeats: 1000, + }), ]; let mut failures = Vec::new(); let mut json_lines = Vec::new(); println!( - "{:>15} {:>15} {:>15} entry point", - "wall time (us)", "expected (us)", "diff(- is impr)" + "{:>13} {:>13} {:>13}{:>13} {:>13} {:>13} entry point", + "walltime(us)", "expected(us)", "dif(- is impr)", "gas/s", "exe gas", "io gas", ); for (index, (expected_time, entry_point)) in entry_points.into_iter().enumerate() { @@ -166,7 +235,7 @@ fn main() { 0, package.publish_transaction_payload(), ); - println!("Published package: {:?}", entry_point.package_name()); + // println!("Published package: {:?}", entry_point.package_name()); if let Some(init_entry_point) = entry_point.initialize_entry_point() { execute_txn( &mut executor, @@ -178,13 +247,13 @@ fn main() { Some(publisher.address()), ), ); - println!( - "Executed init entry point: {:?}", - entry_point.initialize_entry_point() - ); + // println!( + // "Executed init entry point: {:?}", + // entry_point.initialize_entry_point() + // ); } - let elapsed_micros = execute_and_time_entry_point( + let measurement = execute_and_time_entry_point( &entry_point, &package, publisher.address(), @@ -197,33 +266,44 @@ fn main() { 100 }, ); - let diff = (elapsed_micros as f32 - expected_time as f32) / (expected_time as f32) * 100.0; + let diff = (measurement.elapsed_micros as f32 - expected_time as f32) + / (expected_time as f32) + * 100.0; println!( - "{:15} {:15} {:14.1}% {:?}", - elapsed_micros, expected_time, diff, entry_point + "{:13} {:13} {:12.1}% {:13} {:13} {:13} {:?}", + measurement.elapsed_micros, + expected_time, + diff, + (measurement.execution_gas + measurement.io_gas) as u128 / measurement.elapsed_micros, + measurement.execution_gas, + measurement.io_gas, + entry_point ); json_lines.push(json!({ "grep": "grep_json_aptos_move_vm_perf", "transaction_type": format!("{:?}", entry_point), - "wall_time_us": elapsed_micros, + "wall_time_us": measurement.elapsed_micros, + "gps": (measurement.execution_gas + measurement.io_gas) as u128 / measurement.elapsed_micros, + "execution_gas": measurement.execution_gas, + "io_gas": measurement.io_gas, "expected_wall_time_us": expected_time, "test_index": index, })); - if elapsed_micros as f32 + if measurement.elapsed_micros as f32 > expected_time as f32 * (1.0 + ALLOWED_REGRESSION) + ABSOLUTE_BUFFER_US { failures.push(format!( "Performance regression detected: {}us, expected: {}us, diff: {}%, for {:?}", - elapsed_micros, expected_time, diff, entry_point + measurement.elapsed_micros, expected_time, diff, entry_point )); - } else if elapsed_micros as f32 + ABSOLUTE_BUFFER_US + } else if measurement.elapsed_micros as f32 + ABSOLUTE_BUFFER_US < expected_time as f32 * (1.0 - ALLOWED_IMPROVEMENT) { failures.push(format!( "Performance improvement detected: {}us, expected {}us, diff: {}%, for {:?}. You need to adjust expected time!", - elapsed_micros, expected_time, diff, entry_point + measurement.elapsed_micros, expected_time, diff, entry_point )); } } diff --git a/aptos-move/e2e-tests/src/executor.rs b/aptos-move/e2e-tests/src/executor.rs index 018472fe9a9ea..2567031b9f736 100644 --- a/aptos-move/e2e-tests/src/executor.rs +++ b/aptos-move/e2e-tests/src/executor.rs @@ -18,7 +18,7 @@ use aptos_block_executor::txn_commit_hook::NoOpTransactionCommitHook; use aptos_crypto::HashValue; use aptos_framework::ReleaseBundle; use aptos_gas_algebra::DynamicExpression; -use aptos_gas_meter::{StandardGasAlgebra, StandardGasMeter}; +use aptos_gas_meter::{AptosGasMeter, GasAlgebra, StandardGasAlgebra, StandardGasMeter}; use aptos_gas_profiling::{GasProfiler, TransactionGasLog}; use aptos_gas_schedule::{AptosGasParameters, InitialGasSchedule, LATEST_GAS_FEATURE_VERSION}; use aptos_keygen::KeyGen; @@ -134,6 +134,13 @@ pub enum GasMeterType { UnmeteredGasMeter, } +#[derive(Clone)] +pub struct TimeAndGas { + pub elapsed_micros: u128, + pub execution_gas: u64, + pub io_gas: u64, +} + pub enum ExecFuncTimerDynamicArgs { NoArgs, DistinctSigners, @@ -944,7 +951,7 @@ impl FakeExecutor { iterations: u64, dynamic_args: ExecFuncTimerDynamicArgs, gas_meter_type: GasMeterType, - ) -> u128 { + ) -> TimeAndGas { let mut extra_accounts = match &dynamic_args { ExecFuncTimerDynamicArgs::DistinctSigners | ExecFuncTimerDynamicArgs::DistinctSignersAndFixed(_) => (0..iterations) @@ -1041,18 +1048,30 @@ impl FakeExecutor { println!("Shouldn't error, but ignoring for now... {}", err); } } - times.push(elapsed.as_micros()); + times.push(TimeAndGas { + elapsed_micros: elapsed.as_micros(), + execution_gas: regular + .as_ref() + .map_or(0, |gas| gas.algebra().execution_gas_used().into()), + io_gas: regular + .as_ref() + .map_or(0, |gas| gas.algebra().io_gas_used().into()), + }); i += 1; } // take median of all running time iterations as a more robust measurement - times.sort(); + times.sort_by_key(|v| v.elapsed_micros); let length = times.len(); let mid = length / 2; - let mut running_time = times[mid]; + let mut running_time = times[mid].clone(); if length % 2 == 0 { - running_time = (times[mid - 1] + times[mid]) / 2; + running_time = TimeAndGas { + elapsed_micros: (times[mid - 1].elapsed_micros + times[mid].elapsed_micros) / 2, + execution_gas: (times[mid - 1].execution_gas + times[mid].execution_gas) / 2, + io_gas: (times[mid - 1].io_gas + times[mid].io_gas) / 2, + }; } running_time diff --git a/aptos-move/framework/aptos-stdlib/doc/big_vector.md b/aptos-move/framework/aptos-stdlib/doc/big_vector.md index 7d785a5b730a1..da978bc07ff9e 100644 --- a/aptos-move/framework/aptos-stdlib/doc/big_vector.md +++ b/aptos-move/framework/aptos-stdlib/doc/big_vector.md @@ -502,7 +502,7 @@ Aborts if i is out of bounds. if (self.end_index == i) { return last_val }; - // because the lack of mem::swap, here we swap remove the requested value from the bucket + // because the lack of mem::swap, here we swap remove the requested value from the bucket // and append the last_val to the bucket then swap the last bucket val back let bucket = table_with_length::borrow_mut(&mut self.buckets, i / self.bucket_size); let bucket_len = vector::length(bucket); diff --git a/crates/transaction-generator-lib/src/args.rs b/crates/transaction-generator-lib/src/args.rs index 29bcf6dce82df..9c8443f842089 100644 --- a/crates/transaction-generator-lib/src/args.rs +++ b/crates/transaction-generator-lib/src/args.rs @@ -44,6 +44,8 @@ pub enum TransactionTypeArg { CreateObjects100, CreateObjects100WithPayload10k, CreateObjectsConflict100WithPayload10k, + VectorSplitOffAppendLen3000Size1, + VectorRemoveInsertLen3000Size1, ResourceGroupsGlobalWriteTag1KB, ResourceGroupsGlobalWriteAndReadTag1KB, ResourceGroupsSenderWriteTag1KB, @@ -215,6 +217,22 @@ impl TransactionTypeArg { object_payload_size: 10 * 1024, }) }, + TransactionTypeArg::VectorSplitOffAppendLen3000Size1 => { + call_custom_module(EntryPoints::VectorSplitOffAppend { + vec_len: 3000, + element_len: 1, + index: 100, + repeats: 1000, + }) + }, + TransactionTypeArg::VectorRemoveInsertLen3000Size1 => { + call_custom_module(EntryPoints::VectorRemoveInsert { + vec_len: 3000, + element_len: 1, + index: 100, + repeats: 1000, + }) + }, TransactionTypeArg::ResourceGroupsGlobalWriteTag1KB => { call_custom_module(EntryPoints::ResourceGroupsGlobalWriteTag { string_length: 1024, diff --git a/crates/transaction-generator-lib/src/publishing/module_simple.rs b/crates/transaction-generator-lib/src/publishing/module_simple.rs index 3f2e234d220d1..073029c357224 100644 --- a/crates/transaction-generator-lib/src/publishing/module_simple.rs +++ b/crates/transaction-generator-lib/src/publishing/module_simple.rs @@ -226,6 +226,25 @@ pub enum EntryPoints { num_objects: u64, object_payload_size: u64, }, + VectorSplitOffAppend { + vec_len: u64, + element_len: u64, + index: u64, + repeats: u64, + }, + VectorRemoveInsert { + vec_len: u64, + element_len: u64, + index: u64, + repeats: u64, + }, + VectorRangeMove { + vec_len: u64, + element_len: u64, + index: u64, + move_len: u64, + repeats: u64, + }, /// Initialize Token V1 NFT collection TokenV1InitializeCollection, /// Mint an NFT token. Should be called only after InitializeCollection is called @@ -297,6 +316,9 @@ impl EntryPoints { | EntryPoints::ModifyGlobalBoundedAggV2 { .. } | EntryPoints::CreateObjects { .. } | EntryPoints::CreateObjectsConflict { .. } + | EntryPoints::VectorSplitOffAppend { .. } + | EntryPoints::VectorRemoveInsert { .. } + | EntryPoints::VectorRangeMove { .. } | EntryPoints::TokenV1InitializeCollection | EntryPoints::TokenV1MintAndStoreNFTParallel | EntryPoints::TokenV1MintAndStoreNFTSequential @@ -354,6 +376,9 @@ impl EntryPoints { EntryPoints::CreateObjects { .. } | EntryPoints::CreateObjectsConflict { .. } => { "objects" }, + EntryPoints::VectorSplitOffAppend { .. } + | EntryPoints::VectorRemoveInsert { .. } + | EntryPoints::VectorRangeMove { .. } => "vector_example", EntryPoints::TokenV1InitializeCollection | EntryPoints::TokenV1MintAndStoreNFTParallel | EntryPoints::TokenV1MintAndStoreNFTSequential @@ -533,6 +558,51 @@ impl EntryPoints { bcs::to_bytes(other.expect("Must provide other")).unwrap(), ], ), + EntryPoints::VectorSplitOffAppend { + vec_len, + element_len, + index, + repeats, + } + | EntryPoints::VectorRemoveInsert { + vec_len, + element_len, + index, + repeats, + } => get_payload( + module_id, + ident_str!( + if let EntryPoints::VectorSplitOffAppend { .. } = self { + "test_split_off_append" + } else { + "test_remove_insert" + } + ) + .to_owned(), + vec![ + bcs::to_bytes(vec_len).unwrap(), + bcs::to_bytes(element_len).unwrap(), + bcs::to_bytes(index).unwrap(), + bcs::to_bytes(repeats).unwrap(), + ], + ), + EntryPoints::VectorRangeMove { + vec_len, + element_len, + index, + move_len, + repeats, + } => get_payload( + module_id, + ident_str!("test_middle_range_move").to_owned(), + vec![ + bcs::to_bytes(vec_len).unwrap(), + bcs::to_bytes(element_len).unwrap(), + bcs::to_bytes(index).unwrap(), + bcs::to_bytes(move_len).unwrap(), + bcs::to_bytes(repeats).unwrap(), + ], + ), EntryPoints::TokenV1InitializeCollection => get_payload_void( module_id, ident_str!("token_v1_initialize_collection").to_owned(), @@ -799,6 +869,9 @@ impl EntryPoints { EntryPoints::CreateObjects { .. } | EntryPoints::CreateObjectsConflict { .. } => { AutomaticArgs::Signer }, + EntryPoints::VectorSplitOffAppend { .. } + | EntryPoints::VectorRemoveInsert { .. } + | EntryPoints::VectorRangeMove { .. } => AutomaticArgs::None, EntryPoints::TokenV1InitializeCollection | EntryPoints::TokenV1MintAndStoreNFTParallel | EntryPoints::TokenV1MintAndStoreNFTSequential diff --git a/crates/transaction-generator-lib/src/publishing/raw_module_data.rs b/crates/transaction-generator-lib/src/publishing/raw_module_data.rs index c46f5cacc01b3..4174ec34898dd 100644 --- a/crates/transaction-generator-lib/src/publishing/raw_module_data.rs +++ b/crates/transaction-generator-lib/src/publishing/raw_module_data.rs @@ -57,7 +57,7 @@ pub static MODULE_COMPLEX_LIQUIDITY_POOL: Lazy> = Lazy::new(|| { 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 0, 16, 6, 0, 0, 17, 8, 0, 0, 18, 4, 0, 0, 19, 8, 0, 0, 20, 8, 0, 0, 21, 6, 0, 7, 22, 7, 1, 0, 1, 4, - 24, 0, 0, 4, 27, 8, 0, 7, 29, 2, 0, 4, 31, 8, 0, 11, 55, 4, + 24, 0, 0, 4, 27, 11, 0, 7, 29, 2, 0, 4, 31, 8, 0, 11, 55, 4, 2, 0, 0, 0, 0, 4, 60, 6, 0, 4, 62, 6, 0, 4, 64, 6, 0, 12, 70, 4, 1, 0, 0, 13, 86, 7, 0, 8, 93, 7, 1, 0, 0, 0, 23, 0, 1, 0, 0, 25, 2, 3, 0, 0, 26, 4, 5, 0, 0, 28, 6, 7, 0, 0, @@ -495,7 +495,7 @@ pub static MODULE_COMPLEX_LIQUIDITY_POOL_WRAPPER: Lazy> = Lazy::new(|| { 6, 218, 7, 76, 16, 166, 8, 77, 10, 243, 8, 27, 12, 142, 9, 177, 3, 13, 191, 12, 10, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 0, 7, 0, 8, 8, 0, 1, 9, 6, 0, 2, 12, 7, 1, 0, 1, 7, 13, 8, - 0, 1, 22, 8, 0, 1, 24, 0, 0, 2, 26, 2, 0, 3, 28, 7, 1, 0, + 0, 1, 22, 11, 0, 1, 24, 0, 0, 2, 26, 2, 0, 3, 28, 7, 1, 0, 0, 6, 30, 7, 0, 0, 10, 0, 1, 0, 0, 11, 2, 3, 0, 0, 14, 4, 5, 0, 0, 15, 4, 1, 0, 0, 16, 6, 1, 0, 0, 17, 7, 1, 0, 1, 25, 8, 9, 0, 7, 25, 10, 1, 0, 2, 27, 2, 12, 0, 3, 29, 1, 14, @@ -948,11 +948,11 @@ pub static MODULES_SIMPLE: Lazy>> = Lazy::new(|| { vec![ pub static PACKAGE_FRAMEWORK_USECASES_METADATA: Lazy> = Lazy::new(|| { vec![ 17, 70, 114, 97, 109, 101, 119, 111, 114, 107, 85, 115, 101, 99, 97, 115, 101, 115, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 55, 49, 50, 55, 50, 50, 66, 65, - 65, 50, 67, 49, 53, 66, 70, 54, 65, 70, 53, 70, 55, 52, 65, 67, 69, 56, - 51, 68, 53, 66, 66, 54, 66, 67, 56, 56, 49, 69, 66, 67, 68, 66, 66, 57, - 52, 48, 49, 54, 66, 66, 53, 66, 67, 48, 49, 51, 56, 49, 49, 50, 51, 53, - 66, 50, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 68, 65, 51, 57, 67, 70, 69, 56, + 69, 66, 51, 48, 49, 50, 48, 56, 69, 66, 54, 69, 52, 70, 69, 67, 65, 56, + 52, 57, 49, 55, 69, 55, 69, 66, 67, 49, 51, 52, 56, 53, 66, 57, 54, 70, + 69, 65, 51, 54, 50, 56, 50, 49, 66, 54, 57, 65, 48, 57, 54, 49, 54, 68, + 67, 49, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142, 194, 64, 12, 69, 251, 249, 10, 107, 182, 38, 236, 15, 108, 193, 238, 138, 150, 6, 170, 8, 33, 51, 49, 33, 100, 176, 163, 241, 240, 144, 16, 255, 78, 44, 30, 130, 22, 100, 23, 215, 246, 189, 167, 112, 217, 97, 104, 177, 166, 185, 99, 220, 18, 252, @@ -964,13 +964,14 @@ pub static PACKAGE_FRAMEWORK_USECASES_METADATA: Lazy> = Lazy::new(|| { 134, 107, 160, 99, 88, 35, 215, 38, 101, 5, 65, 88, 51, 114, 6, 172, 170, 68, 170, 96, 20, 5, 236, 5, 197, 88, 184, 242, 182, 183, 231, 117, 187, 101, 108, 116, 77, 105, 113, 55, 219, 163, 143, 163, 223, 191, 127, 239, 46, 112, 10, 188, 112, 161, - 1, 0, 0, 6, 18, 97, 103, 103, 114, 101, 103, 97, 116, 111, 114, 95, 101, 120, + 1, 0, 0, 7, 18, 97, 103, 103, 114, 101, 103, 97, 116, 111, 114, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 12, 99, 111, 105, 110, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 22, 102, 117, 110, 103, 105, 98, 108, 101, 95, 97, 115, 115, 101, 116, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 7, 111, 98, 106, 101, 99, 116, 115, 0, 0, 0, 23, 114, 101, 115, 111, 117, 114, 99, 101, 95, 103, 114, 111, 117, 112, 115, 95, 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 8, 116, - 111, 107, 101, 110, 95, 118, 49, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, + 111, 107, 101, 110, 95, 118, 49, 0, 0, 0, 14, 118, 101, 99, 116, 111, 114, 95, + 101, 120, 97, 109, 112, 108, 101, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 65, 112, 116, 111, 115, 70, 114, 97, 109, 101, 119, 111, 114, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1084,7 +1085,7 @@ pub static MODULE_FRAMEWORK_USECASES_FUNGIBLE_ASSET_EXAMPLE: Lazy> = Laz 1, 4, 192, 1, 16, 5, 208, 1, 216, 1, 7, 168, 3, 210, 4, 8, 250, 7, 64, 6, 186, 8, 83, 16, 141, 9, 161, 1, 10, 174, 10, 12, 12, 186, 10, 230, 1, 13, 160, 12, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, - 6, 1, 7, 0, 8, 8, 0, 3, 9, 7, 1, 0, 1, 2, 10, 8, 0, 2, + 6, 1, 7, 0, 8, 8, 0, 3, 9, 7, 1, 0, 1, 2, 10, 11, 0, 2, 17, 6, 0, 2, 19, 6, 0, 2, 21, 6, 0, 3, 24, 2, 0, 4, 26, 7, 1, 0, 0, 7, 28, 7, 0, 2, 35, 0, 0, 2, 36, 8, 0, 0, 11, 0, 1, 0, 0, 12, 2, 3, 0, 0, 13, 4, 3, 0, 0, 14, 5, 3, 0, 0, @@ -1525,6 +1526,59 @@ pub static MODULE_FRAMEWORK_USECASES_TOKEN_V1: Lazy> = Lazy::new(|| { ] }); +#[rustfmt::skip] +pub static MODULE_FRAMEWORK_USECASES_VECTOR_EXAMPLE: Lazy> = Lazy::new(|| { + vec![ + 161, 28, 235, 11, 6, 0, 0, 0, 7, 1, 0, 4, 3, 4, 56, 4, 60, 12, + 5, 72, 98, 7, 170, 1, 149, 1, 8, 191, 2, 64, 12, 255, 2, 166, 3, 0, + 0, 1, 1, 0, 2, 0, 1, 0, 0, 3, 2, 3, 0, 0, 4, 4, 3, 0, + 0, 5, 4, 3, 0, 1, 6, 8, 9, 1, 0, 1, 7, 11, 3, 1, 0, 1, + 8, 13, 9, 1, 0, 1, 9, 8, 3, 1, 0, 1, 10, 13, 14, 1, 0, 1, + 11, 15, 3, 1, 0, 4, 6, 5, 7, 6, 7, 7, 7, 8, 7, 9, 7, 2, + 3, 3, 1, 10, 10, 3, 5, 3, 3, 3, 3, 3, 0, 4, 3, 3, 3, 3, + 9, 1, 1, 3, 3, 10, 3, 10, 3, 3, 3, 10, 10, 3, 1, 3, 1, 10, + 3, 3, 7, 10, 9, 0, 3, 9, 0, 1, 9, 0, 5, 1, 3, 3, 10, 10, + 3, 10, 10, 3, 5, 7, 10, 9, 0, 3, 3, 7, 10, 9, 0, 3, 5, 1, + 3, 3, 10, 3, 10, 10, 3, 2, 7, 10, 9, 0, 3, 1, 10, 9, 0, 2, + 7, 10, 9, 0, 10, 9, 0, 14, 118, 101, 99, 116, 111, 114, 95, 101, 120, 97, + 109, 112, 108, 101, 6, 118, 101, 99, 116, 111, 114, 12, 103, 101, 110, 101, 114, 97, + 116, 101, 95, 118, 101, 99, 22, 116, 101, 115, 116, 95, 109, 105, 100, 100, 108, 101, + 95, 114, 97, 110, 103, 101, 95, 109, 111, 118, 101, 18, 116, 101, 115, 116, 95, 114, + 101, 109, 111, 118, 101, 95, 105, 110, 115, 101, 114, 116, 21, 116, 101, 115, 116, 95, + 115, 112, 108, 105, 116, 95, 111, 102, 102, 95, 97, 112, 112, 101, 110, 100, 7, 114, + 101, 112, 108, 97, 99, 101, 10, 114, 97, 110, 103, 101, 95, 109, 111, 118, 101, 6, + 114, 101, 109, 111, 118, 101, 6, 105, 110, 115, 101, 114, 116, 9, 115, 112, 108, 105, + 116, 95, 111, 102, 102, 6, 97, 112, 112, 101, 110, 100, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 171, 205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 5, 59, 64, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 8, 9, 12, 2, + 11, 1, 12, 4, 10, 2, 4, 15, 11, 8, 6, 1, 0, 0, 0, 0, 0, 0, + 0, 22, 12, 8, 5, 17, 8, 12, 2, 10, 8, 10, 4, 35, 4, 25, 13, 7, + 10, 8, 68, 6, 5, 8, 64, 7, 0, 0, 0, 0, 0, 0, 0, 0, 12, 10, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 9, 9, 12, 3, 11, 0, 12, 5, + 10, 3, 4, 40, 11, 9, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 9, + 5, 42, 8, 12, 3, 10, 9, 10, 5, 35, 4, 57, 10, 7, 12, 6, 13, 6, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 10, 9, 56, 0, 1, 13, 10, 11, 6, + 68, 7, 5, 33, 11, 10, 2, 1, 1, 4, 0, 10, 41, 10, 0, 10, 1, 17, + 0, 12, 8, 11, 0, 11, 1, 17, 0, 12, 9, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 7, 9, 12, 5, 11, 4, 12, 6, 10, 5, 4, 21, 11, 7, 6, + 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 7, 5, 23, 8, 12, 5, 10, 7, + 10, 6, 35, 4, 40, 13, 8, 10, 2, 10, 3, 13, 9, 10, 2, 56, 1, 13, + 9, 10, 2, 10, 3, 13, 8, 10, 2, 56, 1, 5, 14, 2, 2, 1, 4, 0, + 12, 33, 11, 0, 11, 1, 17, 0, 12, 8, 6, 0, 0, 0, 0, 0, 0, 0, + 0, 12, 6, 9, 12, 4, 11, 3, 12, 5, 10, 4, 4, 17, 11, 6, 6, 1, + 0, 0, 0, 0, 0, 0, 0, 22, 12, 6, 5, 19, 8, 12, 4, 10, 6, 10, + 5, 35, 4, 32, 13, 8, 10, 2, 56, 2, 12, 7, 13, 8, 10, 2, 11, 7, + 56, 3, 5, 10, 2, 3, 1, 4, 0, 10, 32, 11, 0, 11, 1, 17, 0, 12, + 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 6, 9, 12, 4, 11, 3, 12, + 5, 10, 4, 4, 17, 11, 6, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, + 6, 5, 19, 8, 12, 4, 10, 6, 10, 5, 35, 4, 31, 13, 8, 10, 2, 56, + 4, 12, 7, 13, 8, 11, 7, 56, 5, 5, 10, 2, 0, + ] +}); + #[rustfmt::skip] pub static MODULES_FRAMEWORK_USECASES: Lazy>> = Lazy::new(|| { vec![ MODULE_FRAMEWORK_USECASES_AGGREGATOR_EXAMPLE.to_vec(), @@ -1533,6 +1587,7 @@ pub static MODULES_FRAMEWORK_USECASES: Lazy>> = Lazy::new(|| { vec![ MODULE_FRAMEWORK_USECASES_OBJECTS.to_vec(), MODULE_FRAMEWORK_USECASES_RESOURCE_GROUPS_EXAMPLE.to_vec(), MODULE_FRAMEWORK_USECASES_TOKEN_V1.to_vec(), + MODULE_FRAMEWORK_USECASES_VECTOR_EXAMPLE.to_vec(), ]}); #[rustfmt::skip] pub static PACKAGE_AMBASSADOR_TOKEN_METADATA: Lazy> = Lazy::new(|| { @@ -1780,11 +1835,11 @@ pub static MODULES_AMBASSADOR_TOKEN: Lazy>> = Lazy::new(|| { vec![ pub static PACKAGE_AGGREGATOR_EXAMPLES_METADATA: Lazy> = Lazy::new(|| { vec![ 19, 65, 103, 103, 114, 101, 103, 97, 116, 111, 114, 32, 101, 120, 97, 109, 112, 108, - 101, 115, 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 69, 55, 68, 49, 68, 70, - 69, 51, 70, 65, 54, 67, 56, 55, 55, 68, 48, 69, 68, 68, 50, 57, 51, 52, - 54, 55, 67, 49, 51, 49, 53, 53, 51, 50, 52, 57, 56, 49, 53, 48, 67, 68, - 69, 51, 52, 50, 68, 50, 65, 66, 50, 66, 50, 53, 57, 52, 53, 50, 52, 68, - 69, 51, 70, 48, 162, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 141, 142, + 101, 115, 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 68, 67, 55, 51, 49, 57, + 51, 57, 49, 54, 57, 50, 56, 54, 56, 57, 49, 55, 68, 67, 56, 51, 68, 70, + 52, 70, 65, 55, 66, 50, 65, 51, 67, 68, 52, 55, 55, 49, 49, 54, 69, 57, + 52, 70, 50, 54, 51, 52, 67, 65, 51, 48, 53, 56, 53, 48, 52, 65, 56, 69, + 69, 53, 51, 70, 162, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 141, 142, 65, 10, 195, 32, 16, 69, 247, 158, 66, 220, 215, 244, 2, 93, 72, 105, 46, 208, 101, 8, 101, 170, 83, 145, 24, 21, 71, 218, 64, 233, 221, 171, 41, 201, 186, 204, 108, 62, 255, 61, 248, 67, 2, 61, 129, 197, 145, 5, 152, 145, 159, 184, 80, 214, diff --git a/testsuite/module-publish/src/packages/framework_usecases/sources/vector_example.move b/testsuite/module-publish/src/packages/framework_usecases/sources/vector_example.move new file mode 100644 index 0000000000000..1308eddc1f5e9 --- /dev/null +++ b/testsuite/module-publish/src/packages/framework_usecases/sources/vector_example.move @@ -0,0 +1,47 @@ + +/// test speed of vector operations +module 0xABCD::vector_example { + use std::vector; + + fun generate_vec(vec_len: u64, element_len: u64): vector> { + let elem = vector::empty(); + for (i in 0..element_len) { + vector::push_back(&mut elem, i); + }; + let vec = vector::empty(); + for (i in 0..vec_len) { + let cur = elem; + vector::replace(&mut cur, 0, i); + vector::push_back(&mut vec, cur); + }; + vec + } + + public entry fun test_split_off_append(vec_len: u64, element_len: u64, index: u64, repeats: u64) { + let vec = generate_vec(vec_len, element_len); + + for (i in 0..repeats) { + let part = vector::split_off(&mut vec, index); + vector::append(&mut vec, part); + }; + } + + public entry fun test_remove_insert(vec_len: u64, element_len: u64, index: u64, repeats: u64) { + let vec = generate_vec(vec_len, element_len); + + for (i in 0..repeats) { + let part = vector::remove(&mut vec, index); + vector::insert(&mut vec, index, part); + }; + } + + public entry fun test_middle_range_move(vec_len: u64, element_len: u64, index: u64, move_len: u64, repeats: u64) { + let vec1 = generate_vec(vec_len, element_len); + let vec2 = generate_vec(vec_len, element_len); + + for (i in 0..repeats) { + vector::range_move(&mut vec1, index, move_len, &mut vec2, index); + vector::range_move(&mut vec2, index, move_len, &mut vec1, index); + }; + } +} diff --git a/testsuite/single_node_performance.py b/testsuite/single_node_performance.py index 3914acfbce9f1..1b3ee273a82e2 100755 --- a/testsuite/single_node_performance.py +++ b/testsuite/single_node_performance.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright © Aptos Foundation # SPDX-License-Identifier: Apache-2.0 @@ -280,6 +280,9 @@ class RunGroupConfig: RunGroupConfig(key=RunGroupKey("no-op-fee-payer"), included_in=LAND_BLOCKING_AND_C), RunGroupConfig(key=RunGroupKey("no-op-fee-payer", module_working_set_size=DEFAULT_MODULE_WORKING_SET_SIZE), included_in=Flow.CONTINUOUS), + RunGroupConfig(expected_tps=394, key=RunGroupKey("vector-split-off-append-len3000-size1"), included_in=Flow.CONTINUOUS, waived=True), + RunGroupConfig(expected_tps=398, key=RunGroupKey("vector-remove-insert-len3000-size1"), included_in=Flow.CONTINUOUS, waived=True), + RunGroupConfig(expected_tps=50000, key=RunGroupKey("coin_transfer_connected_components", executor_type="sharded"), key_extra=RunGroupKeyExtra(sharding_traffic_flags="--connected-tx-grps 5000", transaction_type_override=""), included_in=Flow.REPRESENTATIVE, waived=True), RunGroupConfig(expected_tps=50000, key=RunGroupKey("coin_transfer_hotspot", executor_type="sharded"), key_extra=RunGroupKeyExtra(sharding_traffic_flags="--hotspot-probability 0.8", transaction_type_override=""), included_in=Flow.REPRESENTATIVE, waived=True),