@@ -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 ;
89use once_cell:: sync:: Lazy ;
910
1011pub 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