Skip to content

Commit

Permalink
shorter counter variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Oct 1, 2024
1 parent 860fb8e commit 5c4772b
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 148 deletions.
19 changes: 9 additions & 10 deletions execution/executor-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ use aptos_db::AptosDB;
use aptos_executor::{
block_executor::{BlockExecutor, TransactionBlockExecutor},
metrics::{
APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS, APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS,
APTOS_EXECUTOR_LEDGER_UPDATE_SECONDS, APTOS_EXECUTOR_OTHER_TIMERS_SECONDS,
APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS, APTOS_PROCESSED_TXNS_OUTPUT_SIZE,
COMMIT_BLOCKS, EXECUTE_BLOCK, OTHER_TIMERS, PROCESSED_TXNS_OUTPUT_SIZE, UPDATE_LEDGER,
VM_EXECUTE_BLOCK,
},
};
use aptos_jellyfish_merkle::metrics::{
Expand Down Expand Up @@ -536,29 +535,29 @@ struct ExecutionTimeMeasurement {

impl ExecutionTimeMeasurement {
pub fn now() -> Self {
let output_size = APTOS_PROCESSED_TXNS_OUTPUT_SIZE
let output_size = PROCESSED_TXNS_OUTPUT_SIZE
.with_label_values(&["execution"])
.get_sample_sum();

let partitioning_total = BLOCK_PARTITIONING_SECONDS.get_sample_sum();
let execution_total = APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS.get_sample_sum();
let vm_only = APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum();
let execution_total = EXECUTE_BLOCK.get_sample_sum();
let vm_only = VM_EXECUTE_BLOCK.get_sample_sum();

let by_other = OTHER_LABELS
.iter()
.map(|(_prefix, _top_level, other_label)| {
(
*other_label,
APTOS_EXECUTOR_OTHER_TIMERS_SECONDS
OTHER_TIMERS
.with_label_values(&[other_label])
.get_sample_sum(),
)
})
.collect::<HashMap<_, _>>();
let ledger_update_total = APTOS_EXECUTOR_LEDGER_UPDATE_SECONDS.get_sample_sum();
let commit_total = APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS.get_sample_sum();
let ledger_update_total = UPDATE_LEDGER.get_sample_sum();
let commit_total = COMMIT_BLOCKS.get_sample_sum();

let vm_time = APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum();
let vm_time = VM_EXECUTE_BLOCK.get_sample_sum();

Self {
output_size,
Expand Down
17 changes: 7 additions & 10 deletions execution/executor-benchmark/src/transaction_committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use aptos_crypto::hash::HashValue;
use aptos_db::metrics::API_LATENCY_SECONDS;
use aptos_executor::{
block_executor::{BlockExecutor, TransactionBlockExecutor},
metrics::{
APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS, APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS,
APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS,
},
metrics::{COMMIT_BLOCKS, EXECUTE_BLOCK, VM_EXECUTE_BLOCK},
};
use aptos_executor_types::BlockExecutorTrait;
use aptos_logger::prelude::*;
Expand Down Expand Up @@ -136,19 +133,19 @@ fn report_block(
);
info!(
"Accumulative total: VM time: {:.0} secs, executor time: {:.0} secs, commit time: {:.0} secs, DB commit time: {:.0} secs",
APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum(),
APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS.get_sample_sum() - APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum(),
APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS.get_sample_sum(),
VM_EXECUTE_BLOCK.get_sample_sum(),
EXECUTE_BLOCK.get_sample_sum() - VM_EXECUTE_BLOCK.get_sample_sum(),
COMMIT_BLOCKS.get_sample_sum(),
API_LATENCY_SECONDS.get_metric_with_label_values(&["save_transactions", "Ok"]).expect("must exist.").get_sample_sum(),
);
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
info!(
"Accumulative per transaction: VM time: {:.0} ns, executor time: {:.0} ns, commit time: {:.0} ns, DB commit time: {:.0} ns",
APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum() * NANOS_PER_SEC
VM_EXECUTE_BLOCK.get_sample_sum() * NANOS_PER_SEC
/ total_versions,
(APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS.get_sample_sum() - APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.get_sample_sum()) * NANOS_PER_SEC
(EXECUTE_BLOCK.get_sample_sum() - VM_EXECUTE_BLOCK.get_sample_sum()) * NANOS_PER_SEC
/ total_versions,
APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS.get_sample_sum() * NANOS_PER_SEC
COMMIT_BLOCKS.get_sample_sum() * NANOS_PER_SEC
/ total_versions,
API_LATENCY_SECONDS.get_metric_with_label_values(&["save_transactions", "Ok"]).expect("must exist.").get_sample_sum() * NANOS_PER_SEC
/ total_versions,
Expand Down
30 changes: 12 additions & 18 deletions execution/executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ use crate::{
},
logging::{LogEntry, LogSchema},
metrics::{
APTOS_CHUNK_EXECUTOR_OTHER_SECONDS, APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS,
APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS, APTOS_EXECUTOR_LEDGER_UPDATE_SECONDS,
APTOS_EXECUTOR_OTHER_TIMERS_SECONDS, APTOS_EXECUTOR_SAVE_TRANSACTIONS_SECONDS,
APTOS_EXECUTOR_TRANSACTIONS_SAVED, APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS,
CONCURRENCY_GAUGE,
CHUNK_OTHER_TIMERS, COMMIT_BLOCKS, CONCURRENCY_GAUGE, EXECUTE_BLOCK, OTHER_TIMERS,
SAVE_TRANSACTIONS, TRANSACTIONS_SAVED, UPDATE_LEDGER, VM_EXECUTE_BLOCK,
},
};
use anyhow::Result;
Expand Down Expand Up @@ -216,7 +213,7 @@ where
parent_block_id: HashValue,
onchain_config: BlockExecutorConfigFromOnchain,
) -> ExecutorResult<StateCheckpointOutput> {
let _timer = APTOS_EXECUTOR_EXECUTE_BLOCK_SECONDS.start_timer();
let _timer = EXECUTE_BLOCK.start_timer();
let ExecutableBlock {
block_id,
transactions,
Expand Down Expand Up @@ -248,9 +245,8 @@ where
)
} else {
let state_view = {
let _timer = APTOS_EXECUTOR_OTHER_TIMERS_SECONDS
.with_label_values(&["verified_state_view"])
.start_timer();
let _timer = OTHER_TIMERS.timer_with(&["verified_state_view"]);

info!("next_version: {}", parent_output.next_version());
CachedStateView::new(
StateViewId::BlockExecution { block_id },
Expand All @@ -262,7 +258,7 @@ where
};

let chunk_output = {
let _timer = APTOS_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS.start_timer();
let _timer = VM_EXECUTE_BLOCK.start_timer();
fail_point!("executor::vm_execute_block", |_| {
Err(ExecutorError::from(anyhow::anyhow!(
"Injected error in vm_execute_block"
Expand All @@ -271,9 +267,7 @@ where
V::execute_transaction_block(transactions, state_view, onchain_config.clone())?
};

let _timer = APTOS_EXECUTOR_OTHER_TIMERS_SECONDS
.with_label_values(&["state_checkpoint"])
.start_timer();
let _timer = OTHER_TIMERS.timer_with(&["state_checkpoint"]);

THREAD_MANAGER.get_exe_cpu_pool().install(|| {
chunk_output.into_state_checkpoint_output(parent_output.state(), block_id)
Expand All @@ -294,7 +288,7 @@ where
parent_block_id: HashValue,
state_checkpoint_output: StateCheckpointOutput,
) -> ExecutorResult<StateComputeResult> {
let _timer = APTOS_EXECUTOR_LEDGER_UPDATE_SECONDS.start_timer();
let _timer = UPDATE_LEDGER.start_timer();
info!(
LogSchema::new(LogEntry::BlockExecutor).block_id(block_id),
"ledger_update"
Expand Down Expand Up @@ -358,7 +352,7 @@ where
block_id: HashValue,
parent_block_id: HashValue,
) -> ExecutorResult<()> {
let _timer = APTOS_EXECUTOR_COMMIT_BLOCKS_SECONDS.start_timer();
let _timer = COMMIT_BLOCKS.start_timer();
info!(
LogSchema::new(LogEntry::BlockExecutor).block_id(block_id),
"pre_commit_block",
Expand All @@ -376,7 +370,7 @@ where

let ledger_update = block.output.get_ledger_update();
if !ledger_update.transactions_to_commit().is_empty() {
let _timer = APTOS_EXECUTOR_SAVE_TRANSACTIONS_SECONDS.start_timer();
let _timer = SAVE_TRANSACTIONS.start_timer();
self.db.writer.pre_commit_ledger(
ledger_update.transactions_to_commit(),
ledger_update.first_version(),
Expand All @@ -387,14 +381,14 @@ where
ledger_update.state_updates_until_last_checkpoint.clone(),
Some(&ledger_update.sharded_state_cache),
)?;
APTOS_EXECUTOR_TRANSACTIONS_SAVED.observe(ledger_update.num_txns() as f64);
TRANSACTIONS_SAVED.observe(ledger_update.num_txns() as f64);
}

Ok(())
}

fn commit_ledger(&self, ledger_info_with_sigs: LedgerInfoWithSignatures) -> ExecutorResult<()> {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["commit_ledger"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["commit_ledger"]);

let block_id = ledger_info_with_sigs.ledger_info().consensus_block_id();
info!(
Expand Down
66 changes: 28 additions & 38 deletions execution/executor/src/chunk_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use crate::{
},
logging::{LogEntry, LogSchema},
metrics::{
APTOS_CHUNK_EXECUTOR_OTHER_SECONDS, APTOS_EXECUTOR_APPLY_CHUNK_SECONDS,
APTOS_EXECUTOR_COMMIT_CHUNK_SECONDS, APTOS_EXECUTOR_EXECUTE_CHUNK_SECONDS,
APTOS_EXECUTOR_VM_EXECUTE_CHUNK_SECONDS, CONCURRENCY_GAUGE,
APPLY_CHUNK, CHUNK_OTHER_TIMERS, COMMIT_CHUNK, CONCURRENCY_GAUGE, EXECUTE_CHUNK,
VM_EXECUTE_CHUNK,
},
};
use anyhow::{anyhow, ensure, Result};
Expand Down Expand Up @@ -227,16 +226,15 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
}

fn commit_chunk_impl(&self) -> Result<ExecutedChunk> {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["commit_chunk_impl__total"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["commit_chunk_impl__total"]);
let (persisted_state, chunk) = {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["commit_chunk_impl__next_chunk_to_commit"]);
let _timer =
CHUNK_OTHER_TIMERS.timer_with(&["commit_chunk_impl__next_chunk_to_commit"]);
self.commit_queue.lock().next_chunk_to_commit()?
};

if chunk.ledger_info.is_some() || !chunk.transactions_to_commit().is_empty() {
let _timer =
APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["commit_chunk_impl__save_txns"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["commit_chunk_impl__save_txns"]);
fail_point!("executor::commit_chunk", |_| {
Err(anyhow::anyhow!("Injected error in commit_chunk"))
});
Expand All @@ -258,8 +256,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {

DEFAULT_DROPPER.schedule_drop(persisted_state);

let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["commit_chunk_impl__dequeue_and_return"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["commit_chunk_impl__dequeue_and_return"]);
self.commit_queue
.lock()
.dequeue_committed(chunk.result_state.clone())?;
Expand All @@ -274,7 +271,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
verified_target_li: &LedgerInfoWithSignatures,
epoch_change_li: Option<&LedgerInfoWithSignatures>,
) -> Result<()> {
let _timer = APTOS_EXECUTOR_EXECUTE_CHUNK_SECONDS.start_timer();
let _timer = EXECUTE_CHUNK.start_timer();

let num_txns = txn_list_with_proof.transactions.len();
ensure!(num_txns != 0, "Empty transaction list!");
Expand All @@ -290,17 +287,13 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
);

{
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["enqueue_chunk_by_execution__verify_chunk"]);
THREAD_MANAGER
.get_exe_cpu_pool()
.install(|| -> Result<()> {
verify_chunk(
&txn_list_with_proof,
verified_target_li,
Some(first_version_in_request),
)
})?;
let _timer =
CHUNK_OTHER_TIMERS.timer_with(&["enqueue_chunk_by_execution__verify_chunk"]);
verify_chunk(
&txn_list_with_proof,
verified_target_li,
Some(first_version_in_request),
)?;
}

let TransactionListWithProof {
Expand Down Expand Up @@ -331,7 +324,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
// Execute transactions.
let state_view = self.latest_state_view(&parent_state)?;
let chunk_output = {
let _timer = APTOS_EXECUTOR_VM_EXECUTE_CHUNK_SECONDS.start_timer();
let _timer = VM_EXECUTE_CHUNK.start_timer();
// State sync executor shouldn't have block gas limit.
ChunkOutput::by_transaction_execution::<V>(
sig_verified_txns.into(),
Expand Down Expand Up @@ -378,7 +371,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
verified_target_li: &LedgerInfoWithSignatures,
epoch_change_li: Option<&LedgerInfoWithSignatures>,
) -> Result<()> {
let _timer = APTOS_EXECUTOR_APPLY_CHUNK_SECONDS.start_timer();
let _timer = APPLY_CHUNK.start_timer();

let num_txns = txn_output_list_with_proof.transactions_and_outputs.len();
ensure!(num_txns != 0, "Empty transaction list!");
Expand All @@ -394,7 +387,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
);

{
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["apply_chunk__verify"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["apply_chunk__verify"]);
// Verify input transaction list.
THREAD_MANAGER
.get_exe_cpu_pool()
Expand Down Expand Up @@ -425,8 +418,8 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {

// Calculate state snapshot
let (result_state, next_epoch_state, state_checkpoint_output) = {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["apply_chunk__calculate_state_checkpoint"]);
let _timer =
CHUNK_OTHER_TIMERS.timer_with(&["apply_chunk__calculate_state_checkpoint"]);
ApplyChunkOutput::calculate_state_checkpoint(
chunk_output,
&self.commit_queue.lock().latest_state(),
Expand All @@ -436,8 +429,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
)?
};

let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["apply_chunk__enqueue_for_ledger_update"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["apply_chunk__enqueue_for_ledger_update"]);
// Enqueue for next stage.
self.commit_queue
.lock()
Expand All @@ -461,11 +453,10 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
}

pub fn update_ledger(&self) -> Result<()> {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["chunk_update_ledger_total"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["chunk_update_ledger_total"]);

let (parent_accumulator, chunk) = {
let _timer =
APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["chunk_update_ledger__next_chunk"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["chunk_update_ledger__next_chunk"]);
self.commit_queue.lock().next_chunk_to_update_ledger()?
};
let ChunkToUpdateLedger {
Expand All @@ -485,8 +476,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
)?;

let (ledger_update_output, to_discard, to_retry) = {
let _timer =
APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["chunk_update_ledger__calculate"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["chunk_update_ledger__calculate"]);
ApplyChunkOutput::calculate_ledger_update(state_checkpoint_output, parent_accumulator)?
};
ensure!(to_discard.is_empty(), "Unexpected discard.");
Expand All @@ -507,7 +497,7 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
};
let num_txns = executed_chunk.transactions_to_commit().len();

let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS.timer_with(&["chunk_update_ledger__save"]);
let _timer = CHUNK_OTHER_TIMERS.timer_with(&["chunk_update_ledger__save"]);
self.commit_queue
.lock()
.save_ledger_update_output(executed_chunk)?;
Expand All @@ -521,13 +511,13 @@ impl<V: VMExecutor> ChunkExecutorInner<V> {
}

fn commit_chunk(&self) -> Result<ChunkCommitNotification> {
let _timer = APTOS_EXECUTOR_COMMIT_CHUNK_SECONDS.start_timer();
let _timer = COMMIT_CHUNK.start_timer();
let executed_chunk = self.commit_chunk_impl()?;
self.has_pending_pre_commit.store(false, Ordering::Release);

let commit_notification = {
let _timer = APTOS_CHUNK_EXECUTOR_OTHER_SECONDS
.timer_with(&["commit_chunk__into_chunk_commit_notification"]);
let _timer =
CHUNK_OTHER_TIMERS.timer_with(&["commit_chunk__into_chunk_commit_notification"]);
executed_chunk.into_chunk_commit_notification()
};

Expand Down
Loading

0 comments on commit 5c4772b

Please sign in to comment.