Skip to content

Commit

Permalink
[comments] Use rw lock for module cache, but aquire before block exec…
Browse files Browse the repository at this point in the history
…utions
  • Loading branch information
georgemitenkov committed Nov 13, 2024
1 parent 003ecea commit 1a54836
Show file tree
Hide file tree
Showing 34 changed files with 657 additions and 887 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

12 changes: 6 additions & 6 deletions aptos-move/aptos-debugger/src/aptos_debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

use anyhow::{bail, format_err, Result};
use aptos_block_executor::{
code_cache_global_manager::ModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
code_cache_global_manager::AptosModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
};
use aptos_gas_profiling::{GasProfiler, TransactionGasLog};
use aptos_rest_client::Client;
use aptos_types::{
account_address::AccountAddress,
block_executor::config::{
BlockExecutorConfig, BlockExecutorConfigFromOnchain, BlockExecutorLocalConfig,
block_executor::{
config::{BlockExecutorConfig, BlockExecutorConfigFromOnchain, BlockExecutorLocalConfig},
execution_state::TransactionSliceMetadata,
},
contract_event::ContractEvent,
state_store::TStateView,
Expand Down Expand Up @@ -433,13 +434,12 @@ fn execute_block_no_limit(
BlockAptosVM::execute_block::<_, NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>>(
sig_verified_txns,
state_view,
&ModuleCacheManager::new(),
&AptosModuleCacheManager::new(),
BlockExecutorConfig {
local: BlockExecutorLocalConfig::default_with_concurrency_level(concurrency_level),
onchain: BlockExecutorConfigFromOnchain::new_no_block_limit(),
},
None,
None,
TransactionSliceMetadata::unknown(),
None,
)
.map(BlockOutput::into_transaction_outputs_forced)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::transactions;
use aptos_bitvec::BitVec;
use aptos_block_executor::{
code_cache_global_manager::ModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
code_cache_global_manager::AptosModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
};
use aptos_block_partitioner::{
v2::config::PartitionerV2Config, BlockPartitioner, PartitionerConfig,
Expand All @@ -18,6 +18,7 @@ use aptos_language_e2e_tests::{
use aptos_types::{
block_executor::{
config::{BlockExecutorConfig, BlockExecutorConfigFromOnchain},
execution_state::TransactionSliceMetadata,
partitioner::PartitionedTransactions,
},
block_metadata::BlockMetadata,
Expand Down Expand Up @@ -220,10 +221,9 @@ where
>(
transactions,
self.state_view.as_ref(),
&ModuleCacheManager::new(),
&AptosModuleCacheManager::new(),
BlockExecutorConfig::new_maybe_block_limit(1, maybe_block_gas_limit),
None,
None,
TransactionSliceMetadata::unknown(),
None,
)
.expect("VM should not fail to start")
Expand Down Expand Up @@ -271,13 +271,12 @@ where
>(
transactions,
self.state_view.as_ref(),
&ModuleCacheManager::new(),
&AptosModuleCacheManager::new(),
BlockExecutorConfig::new_maybe_block_limit(
concurrency_level_per_shard,
maybe_block_gas_limit,
),
None,
None,
TransactionSliceMetadata::unknown(),
None,
)
.expect("VM should not fail to start")
Expand Down
17 changes: 7 additions & 10 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
};
use anyhow::anyhow;
use aptos_block_executor::{
code_cache_global_manager::ModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
code_cache_global_manager::AptosModuleCacheManager, txn_commit_hook::NoOpTransactionCommitHook,
};
use aptos_crypto::HashValue;
use aptos_framework::{
Expand All @@ -49,6 +49,7 @@ use aptos_types::{
BlockExecutorConfig, BlockExecutorConfigFromOnchain, BlockExecutorLocalConfig,
BlockExecutorModuleCacheLocalConfig,
},
execution_state::TransactionSliceMetadata,
partitioner::PartitionedTransactions,
},
block_metadata::BlockMetadata,
Expand All @@ -70,7 +71,6 @@ use aptos_types::{
TransactionAuxiliaryData, TransactionOutput, TransactionPayload, TransactionStatus,
VMValidatorResult, ViewFunctionOutput, WriteSetPayload,
},
vm::modules::AptosModuleExtension,
vm_status::{AbortLocation, StatusCode, VMStatus},
};
use aptos_utils::aptos_try;
Expand Down Expand Up @@ -117,7 +117,7 @@ use move_vm_metrics::{Timer, VM_TIMER};
use move_vm_runtime::{
logging::expect_no_verification_errors,
module_traversal::{TraversalContext, TraversalStorage},
Module, RuntimeEnvironment, WithRuntimeEnvironment,
RuntimeEnvironment, WithRuntimeEnvironment,
};
use move_vm_types::gas::{GasMeter, UnmeteredGasMeter};
use num_cpus;
Expand Down Expand Up @@ -2782,14 +2782,13 @@ impl AptosVM {
pub struct AptosVMBlockExecutor {
/// Manages module cache and execution environment of this block executor. Users of executor
/// must use manager's API to ensure the correct state of caches.
module_cache_manager:
ModuleCacheManager<HashValue, ModuleId, CompiledModule, Module, AptosModuleExtension>,
module_cache_manager: AptosModuleCacheManager,
}

impl VMBlockExecutor for AptosVMBlockExecutor {
fn new() -> Self {
Self {
module_cache_manager: ModuleCacheManager::new(),
module_cache_manager: AptosModuleCacheManager::new(),
}
}

Expand All @@ -2798,8 +2797,7 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
transactions: &[SignatureVerifiedTransaction],
state_view: &(impl StateView + Sync),
onchain_config: BlockExecutorConfigFromOnchain,
parent_block: Option<&HashValue>,
current_block: Option<HashValue>,
transaction_slice_metadata: TransactionSliceMetadata,
) -> Result<BlockOutput<TransactionOutput>, VMStatus> {
fail_point!("move_adapter::execute_block", |_| {
Err(VMStatus::error(
Expand Down Expand Up @@ -2831,8 +2829,7 @@ impl VMBlockExecutor for AptosVMBlockExecutor {
},
onchain: onchain_config,
},
parent_block,
current_block,
transaction_slice_metadata,
None,
);
if ret.is_ok() {
Expand Down
Loading

0 comments on commit 1a54836

Please sign in to comment.