Skip to content

Commit 2759c32

Browse files
authored
Parallel tests (aptos-labs#9107)
1 parent c6b9bba commit 2759c32

File tree

15 files changed

+865
-761
lines changed

15 files changed

+865
-761
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aptos-move/aptos-vm/src/block_executor/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,8 @@ impl BlockExecutorTransactionOutput for AptosTransactionOutput {
130130
);
131131
}
132132

133-
/// Return the amount of gas consumed by the transaction.
134-
fn gas_used(&self) -> u64 {
135-
self.committed_output
136-
.get()
137-
.map_or(0, |output| output.gas_used())
138-
}
139-
140-
// Return the fee statement of the transaction.
141-
// Should never be called after vm_output is consumed.
133+
/// Return the fee statement of the transaction.
134+
/// Should never be called after vm_output is consumed.
142135
fn fee_statement(&self) -> FeeStatement {
143136
self.vm_output
144137
.lock()

aptos-move/block-executor/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ aptos-types = { workspace = true }
2424
aptos-vm-logging = { workspace = true }
2525
arc-swap = { workspace = true }
2626
bcs = { workspace = true }
27+
claims = { workspace = true }
2728
criterion = { workspace = true, optional = true }
2829
crossbeam = { workspace = true }
2930
dashmap = { workspace = true }
@@ -36,8 +37,8 @@ proptest-derive = { workspace = true, optional = true }
3637
rayon = { workspace = true }
3738

3839
[dev-dependencies]
39-
claims = { workspace = true }
4040
criterion = { workspace = true }
41+
itertools = { workspace = true }
4142
proptest = { workspace = true }
4243
proptest-derive = { workspace = true }
4344
rand = { workspace = true }

aptos-move/block-executor/benches/scheduler_benches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright © Aptos Foundation
2+
// Parts of the project are originally copyright © Meta Platforms, Inc.
23
// SPDX-License-Identifier: Apache-2.0
34

45
// Run this bencher via `cargo bench --features fuzzing`.
5-
use aptos_parallel_executor::proptest_types::bencher::Bencher;
6+
use aptos_block_executor::proptest_types::bencher::Bencher;
67
use criterion::{criterion_group, criterion_main, Criterion};
78
use proptest::prelude::*;
89

aptos-move/block-executor/src/counters.rs

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use aptos_metrics_core::{
55
exponential_buckets, register_histogram, register_histogram_vec, register_int_counter,
66
register_int_counter_vec, Histogram, HistogramVec, IntCounter, IntCounterVec,
77
};
8+
use aptos_types::fee_statement::FeeStatement;
89
use once_cell::sync::Lazy;
910

1011
pub struct GasType;
@@ -26,28 +27,28 @@ impl Mode {
2627
}
2728

2829
/// Record the block gas during parallel execution.
29-
pub fn observe_parallel_execution_block_gas(cost: u64, gas_type: &'static str) {
30+
fn observe_parallel_execution_block_gas(cost: u64, gas_type: &'static str) {
3031
BLOCK_GAS
3132
.with_label_values(&[Mode::PARALLEL, gas_type])
3233
.observe(cost as f64);
3334
}
3435

3536
/// Record the txn gas during parallel execution.
36-
pub fn observe_parallel_execution_txn_gas(cost: u64, gas_type: &'static str) {
37+
fn observe_parallel_execution_txn_gas(cost: u64, gas_type: &'static str) {
3738
TXN_GAS
3839
.with_label_values(&[Mode::PARALLEL, gas_type])
3940
.observe(cost as f64);
4041
}
4142

4243
/// Record the block gas during sequential execution.
43-
pub fn observe_sequential_execution_block_gas(cost: u64, gas_type: &'static str) {
44+
fn observe_sequential_execution_block_gas(cost: u64, gas_type: &'static str) {
4445
BLOCK_GAS
4546
.with_label_values(&[Mode::SEQUENTIAL, gas_type])
4647
.observe(cost as f64);
4748
}
4849

4950
/// Record the txn gas during sequential execution.
50-
pub fn observe_sequential_execution_txn_gas(cost: u64, gas_type: &'static str) {
51+
fn observe_sequential_execution_txn_gas(cost: u64, gas_type: &'static str) {
5152
TXN_GAS
5253
.with_label_values(&[Mode::SEQUENTIAL, gas_type])
5354
.observe(cost as f64);
@@ -194,3 +195,95 @@ pub static BLOCK_COMMITTED_TXNS: Lazy<HistogramVec> = Lazy::new(|| {
194195
)
195196
.unwrap()
196197
});
198+
199+
pub(crate) fn update_parallel_block_gas_counters(
200+
accumulated_fee_statement: &FeeStatement,
201+
num_committed: usize,
202+
) {
203+
observe_parallel_execution_block_gas(accumulated_fee_statement.gas_used(), GasType::TOTAL_GAS);
204+
observe_parallel_execution_block_gas(
205+
accumulated_fee_statement.execution_gas_used(),
206+
GasType::EXECUTION_GAS,
207+
);
208+
observe_parallel_execution_block_gas(accumulated_fee_statement.io_gas_used(), GasType::IO_GAS);
209+
observe_parallel_execution_block_gas(
210+
accumulated_fee_statement.storage_gas_used(),
211+
GasType::STORAGE_GAS,
212+
);
213+
observe_parallel_execution_block_gas(
214+
accumulated_fee_statement.execution_gas_used() + accumulated_fee_statement.io_gas_used(),
215+
GasType::NON_STORAGE_GAS,
216+
);
217+
observe_parallel_execution_block_gas(
218+
accumulated_fee_statement.storage_fee_used(),
219+
GasType::STORAGE_FEE,
220+
);
221+
BLOCK_COMMITTED_TXNS
222+
.with_label_values(&[Mode::PARALLEL])
223+
.observe(num_committed as f64);
224+
}
225+
226+
pub(crate) fn update_parallel_txn_gas_counters(txn_fee_statements: &Vec<FeeStatement>) {
227+
for fee_statement in txn_fee_statements {
228+
observe_parallel_execution_txn_gas(fee_statement.gas_used(), GasType::TOTAL_GAS);
229+
observe_parallel_execution_txn_gas(
230+
fee_statement.execution_gas_used(),
231+
GasType::EXECUTION_GAS,
232+
);
233+
observe_parallel_execution_txn_gas(fee_statement.io_gas_used(), GasType::IO_GAS);
234+
observe_parallel_execution_txn_gas(fee_statement.storage_gas_used(), GasType::STORAGE_GAS);
235+
observe_parallel_execution_txn_gas(
236+
fee_statement.execution_gas_used() + fee_statement.io_gas_used(),
237+
GasType::NON_STORAGE_GAS,
238+
);
239+
observe_parallel_execution_txn_gas(fee_statement.storage_fee_used(), GasType::STORAGE_FEE);
240+
}
241+
}
242+
243+
pub(crate) fn update_sequential_block_gas_counters(
244+
accumulated_fee_statement: &FeeStatement,
245+
num_committed: usize,
246+
) {
247+
observe_sequential_execution_block_gas(
248+
accumulated_fee_statement.gas_used(),
249+
GasType::TOTAL_GAS,
250+
);
251+
observe_sequential_execution_block_gas(
252+
accumulated_fee_statement.execution_gas_used(),
253+
GasType::EXECUTION_GAS,
254+
);
255+
observe_sequential_execution_block_gas(
256+
accumulated_fee_statement.io_gas_used(),
257+
GasType::IO_GAS,
258+
);
259+
observe_sequential_execution_block_gas(
260+
accumulated_fee_statement.storage_gas_used(),
261+
GasType::STORAGE_GAS,
262+
);
263+
observe_sequential_execution_block_gas(
264+
accumulated_fee_statement.execution_gas_used() + accumulated_fee_statement.io_gas_used(),
265+
GasType::NON_STORAGE_GAS,
266+
);
267+
observe_sequential_execution_block_gas(
268+
accumulated_fee_statement.storage_fee_used(),
269+
GasType::STORAGE_FEE,
270+
);
271+
BLOCK_COMMITTED_TXNS
272+
.with_label_values(&[Mode::PARALLEL])
273+
.observe(num_committed as f64);
274+
}
275+
276+
pub(crate) fn update_sequential_txn_gas_counters(fee_statement: &FeeStatement) {
277+
observe_sequential_execution_txn_gas(fee_statement.gas_used(), GasType::TOTAL_GAS);
278+
observe_sequential_execution_txn_gas(
279+
fee_statement.execution_gas_used(),
280+
GasType::EXECUTION_GAS,
281+
);
282+
observe_sequential_execution_txn_gas(fee_statement.io_gas_used(), GasType::IO_GAS);
283+
observe_sequential_execution_txn_gas(fee_statement.storage_gas_used(), GasType::STORAGE_GAS);
284+
observe_sequential_execution_txn_gas(
285+
fee_statement.execution_gas_used() + fee_statement.io_gas_used(),
286+
GasType::NON_STORAGE_GAS,
287+
);
288+
observe_sequential_execution_txn_gas(fee_statement.storage_fee_used(), GasType::STORAGE_FEE);
289+
}

0 commit comments

Comments
 (0)