Skip to content

Commit

Permalink
Various variants of "simplified/dummy" executors (#15152)
Browse files Browse the repository at this point in the history
## Description
Adding all these executor configurations, for understanding upper bounds on different approaches/optimizations:

```
    /// Transaction execution: AptosVM
    /// Executing conflicts: in the input order, via BlockSTM,
    /// State: BlockSTM-provided MVHashMap-based view with caching
    AptosVMWithBlockSTM,
    /// Transaction execution: NativeVM - a simplified rust implemtation to create VMChangeSet,
    /// Executing conflicts: in the input order, via BlockSTM
    /// State: BlockSTM-provided MVHashMap-based view with caching
    NativeVMWithBlockSTM,
    /// Transaction execution: AptosVM
    /// Executing conflicts: All transactions execute on the state at the beginning of the block
    /// State: Raw CachedStateView
    AptosVMParallelUncoordinated,
    /// Transaction execution: Native rust code producing WriteSet
    /// Executing conflicts: All transactions execute on the state at the beginning of the block
    /// State: Raw CachedStateView
    NativeParallelUncoordinated,
    /// Transaction execution: Native rust code updating in-memory state, no WriteSet output
    /// Executing conflicts: All transactions execute on the state in the first come - first serve basis
    /// State: In-memory DashMap with rust values of state (i.e. StateKey -> Resource (either Account or FungibleStore)),
    ///        cached across blocks, filled upon first request
    NativeValueCacheParallelUncoordinated,
    /// Transaction execution: Native rust code updating in-memory state, no WriteSet output
    /// Executing conflicts: All transactions execute on the state in the first come - first serve basis
    /// State: In-memory DashMap with AccountAddress to seq_num and balance (ignoring all other fields).
    ///        kept across blocks, randomly initialized on first access, storage ignored.
    NativeNoStorageParallelUncoordinated,
```
  • Loading branch information
igor-aptos authored Nov 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 32e222b commit 516f32e
Showing 26 changed files with 3,046 additions and 696 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/workflow-run-execution-performance.yaml
Original file line number Diff line number Diff line change
@@ -27,6 +27,11 @@ on:
default: false
type: boolean
description: Whether to run or skip move-only e2e tests at the beginning.
USE_COIN_APT:
required: false
default: false
type: boolean
description: By default, FA APT is exclusively used. If set Coin APT is used instead.
SOURCE:
required: false
default: CI
@@ -74,13 +79,19 @@ on:
- CONTINUOUS
- MAINNET
- MAINNET_LARGE_DB
- EXECUTORS
type: choice
description: Which set of tests to run. MAINNET/MAINNET_LARGE_DB are for performance validation of mainnet nodes.
SKIP_MOVE_E2E:
required: false
default: false
type: boolean
description: Whether to skip move-only e2e tests at the beginning.
USE_COIN_APT:
required: false
default: false
type: boolean
description: By default, FA APT is exclusively used. If set Coin APT is used instead.
IGNORE_TARGET_DETERMINATION:
required: false
default: true
@@ -123,7 +134,7 @@ jobs:

- name: Run single node execution benchmark in performance build mode
shell: bash
run: TABULATE_INSTALL=lib-only pip install tabulate && FLOW="${{ inputs.FLOW }}" SOURCE="${{ inputs.SOURCE }}" RUNNER_NAME="${{ inputs.RUNNER_NAME }}" SKIP_MOVE_E2E="${{ inputs.SKIP_MOVE_E2E && '1' || '' }}" NUMBER_OF_EXECUTION_THREADS="${{ inputs.NUMBER_OF_EXECUTION_THREADS }}" testsuite/single_node_performance.py
run: TABULATE_INSTALL=lib-only pip install tabulate && FLOW="${{ inputs.FLOW }}" SOURCE="${{ inputs.SOURCE }}" RUNNER_NAME="${{ inputs.RUNNER_NAME }}" SKIP_MOVE_E2E="${{ inputs.SKIP_MOVE_E2E && '1' || '' }}" DISABLE_FA_APT="${{ inputs.USE_COIN_APT && '1' || '' }}" NUMBER_OF_EXECUTION_THREADS="${{ inputs.NUMBER_OF_EXECUTION_THREADS }}" testsuite/single_node_performance.py
if: ${{ (inputs.IGNORE_TARGET_DETERMINATION || needs.test-target-determinator.outputs.run_execution_performance_test == 'true') }}

- run: echo "Skipping single node execution performance! Unrelated changes detected."
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion aptos-move/aptos-aggregator/src/resolver.rs
Original file line number Diff line number Diff line change
@@ -86,7 +86,6 @@ pub trait TAggregatorV1View {
PartialVMError::new(StatusCode::SPECULATIVE_EXECUTION_ABORT_ERROR)
.with_message("Cannot convert delta for deleted aggregator".to_string())
})?;

delta_op
.apply_to(base)
.map_err(|e| match &e {
4 changes: 2 additions & 2 deletions aptos-move/aptos-debugger/src/aptos_debugger.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ use aptos_validator_interface::{
AptosValidatorInterface, DBDebuggerInterface, DebuggerStateView, RestDebuggerInterface,
};
use aptos_vm::{
block_executor::{AptosTransactionOutput, BlockAptosVM},
block_executor::{AptosTransactionOutput, AptosVMBlockExecutorWrapper},
data_cache::AsMoveResolver,
AptosVM,
};
@@ -434,7 +434,7 @@ fn execute_block_no_limit(
state_view: &DebuggerStateView,
concurrency_level: usize,
) -> Result<Vec<TransactionOutput>, VMStatus> {
BlockAptosVM::execute_block::<
AptosVMBlockExecutorWrapper::execute_block::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
DefaultTxnProvider<SignatureVerifiedTransaction>,
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ use aptos_types::{
vm_status::VMStatus,
};
use aptos_vm::{
block_executor::{AptosTransactionOutput, BlockAptosVM},
block_executor::{AptosTransactionOutput, AptosVMBlockExecutorWrapper},
data_cache::AsMoveResolver,
sharded_block_executor::{
local_executor_shard::{LocalExecutorClient, LocalExecutorService},
@@ -217,7 +217,7 @@ where
) -> (Vec<TransactionOutput>, usize) {
let block_size = txn_provider.num_txns();
let timer = Instant::now();
let output = BlockAptosVM::execute_block::<
let output = AptosVMBlockExecutorWrapper::execute_block::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
DefaultTxnProvider<SignatureVerifiedTransaction>,
@@ -268,7 +268,7 @@ where
) -> (Vec<TransactionOutput>, usize) {
let block_size = txn_provider.num_txns();
let timer = Instant::now();
let output = BlockAptosVM::execute_block::<
let output = AptosVMBlockExecutorWrapper::execute_block::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
DefaultTxnProvider<SignatureVerifiedTransaction>,
10 changes: 5 additions & 5 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
block_executor::{AptosTransactionOutput, BlockAptosVM},
block_executor::{AptosTransactionOutput, AptosVMBlockExecutorWrapper},
counters::*,
data_cache::{AsMoveResolver, StorageAdapter},
errors::{discarded_output, expect_only_successful_execution},
@@ -22,8 +22,8 @@ use crate::{
sharded_block_executor::{executor_client::ExecutorClient, ShardedBlockExecutor},
system_module_names::*,
transaction_metadata::TransactionMetadata,
transaction_validation, verifier,
verifier::randomness::get_randomness_annotation,
transaction_validation,
verifier::{self, randomness::get_randomness_annotation},
VMBlockExecutor, VMValidator,
};
use anyhow::anyhow;
@@ -2781,7 +2781,7 @@ impl AptosVM {

// TODO - move out from this file?

/// Production implementation of TransactionBlockExecutor.
/// Production implementation of VMBlockExecutor.
///
/// Transaction execution: AptosVM
/// Executing conflicts: in the input order, via BlockSTM,
@@ -2820,7 +2820,7 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
);

let count = txn_provider.num_txns();
let ret = BlockAptosVM::execute_block::<
let ret = AptosVMBlockExecutorWrapper::execute_block::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
DefaultTxnProvider<SignatureVerifiedTransaction>,
55 changes: 37 additions & 18 deletions aptos-move/aptos-vm/src/block_executor/mod.rs
Original file line number Diff line number Diff line change
@@ -4,17 +4,18 @@

pub(crate) mod vm_wrapper;

use crate::{
block_executor::vm_wrapper::AptosExecutorTask,
counters::{BLOCK_EXECUTOR_CONCURRENCY, BLOCK_EXECUTOR_EXECUTE_BLOCK_SECONDS},
};
use crate::counters::{BLOCK_EXECUTOR_CONCURRENCY, BLOCK_EXECUTOR_EXECUTE_BLOCK_SECONDS};
use aptos_aggregator::{
delayed_change::DelayedChange, delta_change_set::DeltaOp, resolver::TAggregatorV1View,
};
use aptos_block_executor::{
code_cache_global_manager::AptosModuleCacheManager, errors::BlockExecutionError,
executor::BlockExecutor, task::TransactionOutput as BlockExecutorTransactionOutput,
txn_commit_hook::TransactionCommitHook, txn_provider::TxnProvider, types::InputOutputKey,
code_cache_global_manager::AptosModuleCacheManager,
errors::BlockExecutionError,
executor::BlockExecutor,
task::{ExecutorTask, TransactionOutput as BlockExecutorTransactionOutput},
txn_commit_hook::TransactionCommitHook,
txn_provider::TxnProvider,
types::InputOutputKey,
};
use aptos_infallible::Mutex;
use aptos_types::{
@@ -46,8 +47,10 @@ use move_vm_types::delayed_values::delayed_field_id::DelayedFieldID;
use once_cell::sync::{Lazy, OnceCell};
use std::{
collections::{BTreeMap, HashSet},
marker::PhantomData,
sync::Arc,
};
use vm_wrapper::AptosExecutorTask;

static RAYON_EXEC_POOL: Lazy<Arc<rayon::ThreadPool>> = Lazy::new(|| {
Arc::new(
@@ -69,7 +72,7 @@ pub struct AptosTransactionOutput {
}

impl AptosTransactionOutput {
pub(crate) fn new(output: VMOutput) -> Self {
pub fn new(output: VMOutput) -> Self {
Self {
vm_output: Mutex::new(Some(output)),
committed_output: OnceCell::new(),
@@ -387,9 +390,24 @@ impl BlockExecutorTransactionOutput for AptosTransactionOutput {
}
}

pub struct BlockAptosVM;
pub struct AptosBlockExecutorWrapper<
E: ExecutorTask<
Txn = SignatureVerifiedTransaction,
Error = VMStatus,
Output = AptosTransactionOutput,
>,
> {
_phantom: PhantomData<E>,
}

impl BlockAptosVM {
impl<
E: ExecutorTask<
Txn = SignatureVerifiedTransaction,
Error = VMStatus,
Output = AptosTransactionOutput,
>,
> AptosBlockExecutorWrapper<E>
{
pub fn execute_block_on_thread_pool<
S: StateView + Sync,
L: TransactionCommitHook<Output = AptosTransactionOutput>,
@@ -420,14 +438,12 @@ impl BlockAptosVM {
transaction_slice_metadata,
)?;

let executor = BlockExecutor::<
SignatureVerifiedTransaction,
AptosExecutorTask,
S,
L,
ExecutableTestType,
TP,
>::new(config, executor_thread_pool, transaction_commit_listener);
let executor =
BlockExecutor::<SignatureVerifiedTransaction, E, S, L, ExecutableTestType, TP>::new(
config,
executor_thread_pool,
transaction_commit_listener,
);

let ret = executor.execute_block(
signature_verified_block,
@@ -488,3 +504,6 @@ impl BlockAptosVM {
)
}
}

// Same as AptosBlockExecutorWrapper with AptosExecutorTask
pub type AptosVMBlockExecutorWrapper = AptosBlockExecutorWrapper<AptosExecutorTask>;
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/block_executor/vm_wrapper.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ use aptos_vm_types::{
use fail::fail_point;
use move_core_types::vm_status::{StatusCode, VMStatus};

pub(crate) struct AptosExecutorTask {
pub struct AptosExecutorTask {
vm: AptosVM,
id: StateViewId,
}
12 changes: 7 additions & 5 deletions aptos-move/aptos-vm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -194,9 +194,11 @@ pub trait VMBlockExecutor: Send + Sync {

/// Executes a block of transactions using a sharded block executor and returns the results.
fn execute_block_sharded<S: StateView + Sync + Send + 'static, E: ExecutorClient<S>>(
sharded_block_executor: &ShardedBlockExecutor<S, E>,
transactions: PartitionedTransactions,
state_view: Arc<S>,
onchain_config: BlockExecutorConfigFromOnchain,
) -> Result<Vec<TransactionOutput>, VMStatus>;
_sharded_block_executor: &ShardedBlockExecutor<S, E>,
_transactions: PartitionedTransactions,
_state_view: Arc<S>,
_onchain_config: BlockExecutorConfigFromOnchain,
) -> Result<Vec<TransactionOutput>, VMStatus> {
unimplemented!("sharded not supported")
}
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
block_executor::BlockAptosVM,
block_executor::AptosVMBlockExecutorWrapper,
sharded_block_executor::{
aggr_overridden_state_view::{AggregatorOverriddenStateView, TOTAL_SUPPLY_AGGR_BASE_VAL},
coordinator_client::CoordinatorClient,
@@ -140,7 +140,7 @@ impl<S: StateView + Sync + Send + 'static> ShardedExecutorService<S> {
});
s.spawn(move |_| {
let txn_provider = DefaultTxnProvider::new(signature_verified_transactions);
let ret = BlockAptosVM::execute_block_on_thread_pool(
let ret = AptosVMBlockExecutorWrapper::execute_block_on_thread_pool(
executor_thread_pool,
&txn_provider,
aggr_overridden_state_view.as_ref(),
4 changes: 2 additions & 2 deletions aptos-move/e2e-tests/src/executor.rs
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ use aptos_types::{
AptosCoinType, CoinType,
};
use aptos_vm::{
block_executor::{AptosTransactionOutput, BlockAptosVM},
block_executor::{AptosTransactionOutput, AptosVMBlockExecutorWrapper},
data_cache::AsMoveResolver,
gas::make_prod_gas_meter,
move_vm_ext::{MoveVmExt, SessionExt, SessionId},
@@ -678,7 +678,7 @@ impl FakeExecutor {
onchain: onchain_config,
};
let txn_provider = DefaultTxnProvider::new(txn_block);
BlockAptosVM::execute_block_on_thread_pool::<
AptosVMBlockExecutorWrapper::execute_block_on_thread_pool::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
_,
7 changes: 7 additions & 0 deletions execution/executor-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ rust-version = { workspace = true }

[dependencies]
anyhow = { workspace = true }
aptos-aggregator = { workspace = true }
aptos-block-executor = { workspace = true }
aptos-block-partitioner = { workspace = true }
aptos-config = { workspace = true }
@@ -28,6 +29,7 @@ aptos-genesis = { workspace = true, features = ["testing"] }
aptos-jellyfish-merkle = { workspace = true }
aptos-logger = { workspace = true }
aptos-metrics-core = { workspace = true }
aptos-mvhashmap = { workspace = true }
aptos-node-resource-metrics = { workspace = true }
aptos-push-metrics = { workspace = true }
aptos-sdk = { workspace = true }
@@ -36,14 +38,19 @@ aptos-transaction-generator-lib = { workspace = true }
aptos-types = { workspace = true }
aptos-vm = { workspace = true }
aptos-vm-environment = { workspace = true }
aptos-vm-logging = { workspace = true }
aptos-vm-types = { workspace = true }
async-trait = { workspace = true }
bcs = { workspace = true }
bytes = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true }
dashmap = { workspace = true }
derivative = { workspace = true }
indicatif = { workspace = true }
itertools = { workspace = true }
move-core-types = { workspace = true }
move-vm-types = { workspace = true }
num_cpus = { workspace = true }
once_cell = { workspace = true }
rand = { workspace = true }
Loading

0 comments on commit 516f32e

Please sign in to comment.