@@ -5,7 +5,7 @@ use crate::{
5
5
storage:: { SchedulerDB , State } ,
6
6
tx_dependency:: { DependentTxsVec , TxDependency } ,
7
7
GrevmError , LocationAndType , ResultAndTransition , TransactionStatus , TxId , CPU_CORES ,
8
- GREVM_RUNTIME , MAX_NUM_ROUND ,
8
+ DEBUG_BOTTLENECK , GREVM_RUNTIME , MAX_NUM_ROUND ,
9
9
} ;
10
10
use ahash:: { AHashMap as HashMap , AHashSet as HashSet } ;
11
11
use atomic:: Atomic ;
@@ -75,6 +75,10 @@ struct ExecuteMetrics {
75
75
commit_transition_time : metrics:: Histogram ,
76
76
/// Time taken to execute transactions in sequential(in nanoseconds).
77
77
sequential_execute_time : metrics:: Histogram ,
78
+ /// Number of transactions that failed to parse contract
79
+ unknown_contract_tx_cnt : metrics:: Histogram ,
80
+ /// Number of raw transactions
81
+ raw_tx_cnt : metrics:: Histogram ,
78
82
}
79
83
80
84
impl Default for ExecuteMetrics {
@@ -100,6 +104,8 @@ impl Default for ExecuteMetrics {
100
104
merge_write_set_time : histogram ! ( "grevm.merge_write_set_time" ) ,
101
105
commit_transition_time : histogram ! ( "grevm.commit_transition_time" ) ,
102
106
sequential_execute_time : histogram ! ( "grevm.sequential_execute_time" ) ,
107
+ unknown_contract_tx_cnt : histogram ! ( "grevm.unknown_contract_tx_cnt" ) ,
108
+ raw_tx_cnt : histogram ! ( "grevm.raw_tx_cnt" ) ,
103
109
}
104
110
}
105
111
}
@@ -127,6 +133,8 @@ struct ExecuteMetricsCollector {
127
133
merge_write_set_time : u64 ,
128
134
commit_transition_time : u64 ,
129
135
sequential_execute_time : u64 ,
136
+ unknown_contract_tx_cnt : u64 ,
137
+ raw_tx_cnt : u64 ,
130
138
}
131
139
132
140
impl ExecuteMetricsCollector {
@@ -152,6 +160,8 @@ impl ExecuteMetricsCollector {
152
160
execute_metrics. merge_write_set_time . record ( self . merge_write_set_time as f64 ) ;
153
161
execute_metrics. commit_transition_time . record ( self . commit_transition_time as f64 ) ;
154
162
execute_metrics. sequential_execute_time . record ( self . sequential_execute_time as f64 ) ;
163
+ execute_metrics. unknown_contract_tx_cnt . record ( self . unknown_contract_tx_cnt as f64 ) ;
164
+ execute_metrics. raw_tx_cnt . record ( self . raw_tx_cnt as f64 ) ;
155
165
}
156
166
}
157
167
@@ -348,9 +358,10 @@ where
348
358
349
359
/// Get the partitioned transactions by dependencies.
350
360
#[ fastrace:: trace]
351
- pub ( crate ) fn partition_transactions ( & mut self ) {
361
+ pub ( crate ) fn partition_transactions ( & mut self , round : usize ) {
352
362
// compute and assign partitioned_txs
353
363
let start = Instant :: now ( ) ;
364
+ self . tx_dependencies . round = Some ( round) ;
354
365
self . partitioned_txs = self . tx_dependencies . fetch_best_partitions ( self . num_partitions ) ;
355
366
self . num_partitions = self . partitioned_txs . len ( ) ;
356
367
let mut max = 0 ;
@@ -412,13 +423,15 @@ where
412
423
let start = Instant :: now ( ) ;
413
424
let mut merged_write_set: HashMap < LocationAndType , BTreeSet < TxId > > = HashMap :: new ( ) ;
414
425
let mut end_skip_id = self . num_finality_txs ;
415
- for txid in self . num_finality_txs ..self . tx_states . len ( ) {
416
- if self . tx_states [ txid] . tx_status == TransactionStatus :: SkipValidation &&
417
- end_skip_id == txid
418
- {
419
- end_skip_id += 1 ;
420
- } else {
421
- break ;
426
+ if !( * DEBUG_BOTTLENECK ) {
427
+ for txid in self . num_finality_txs ..self . tx_states . len ( ) {
428
+ if self . tx_states [ txid] . tx_status == TransactionStatus :: SkipValidation &&
429
+ end_skip_id == txid
430
+ {
431
+ end_skip_id += 1 ;
432
+ } else {
433
+ break ;
434
+ }
422
435
}
423
436
}
424
437
if end_skip_id != self . tx_states . len ( ) {
@@ -438,8 +451,7 @@ where
438
451
/// and there is no need to record the dependency and dependent relationships of these
439
452
/// transactions. Thus achieving the purpose of pruning.
440
453
#[ fastrace:: trace]
441
- fn update_and_pruning_dependency ( & mut self ) {
442
- let num_finality_txs = self . num_finality_txs ;
454
+ fn update_and_pruning_dependency ( & mut self , num_finality_txs : usize ) {
443
455
if num_finality_txs == self . txs . len ( ) {
444
456
return ;
445
457
}
@@ -524,6 +536,13 @@ where
524
536
}
525
537
}
526
538
} ) ;
539
+ if * DEBUG_BOTTLENECK && self . num_finality_txs == 0 {
540
+ // Use the read-write set to build accurate dependencies,
541
+ // and try to find the bottleneck
542
+ self . update_and_pruning_dependency ( 0 ) ;
543
+ self . tx_dependencies . round = None ;
544
+ self . tx_dependencies . fetch_best_partitions ( self . num_partitions ) ;
545
+ }
527
546
miner_involved_txs. into_iter ( ) . collect ( )
528
547
}
529
548
@@ -651,7 +670,7 @@ where
651
670
let miner_involved_txs = self . generate_unconfirmed_txs ( ) ;
652
671
let finality_tx_cnt = self . find_continuous_min_txid ( ) ?;
653
672
// update and pruning tx dependencies
654
- self . update_and_pruning_dependency ( ) ;
673
+ self . update_and_pruning_dependency ( self . num_finality_txs ) ;
655
674
self . commit_transition ( finality_tx_cnt) ?;
656
675
let mut rewards_accumulators = RewardsAccumulators :: new ( ) ;
657
676
for txid in miner_involved_txs {
@@ -721,10 +740,12 @@ where
721
740
#[ fastrace:: trace]
722
741
fn parse_hints ( & mut self ) {
723
742
let start = Instant :: now ( ) ;
724
- let hints = ParallelExecutionHints :: new ( self . tx_states . clone ( ) ) ;
743
+ let mut hints = ParallelExecutionHints :: new ( self . tx_states . clone ( ) ) ;
725
744
hints. parse_hints ( self . txs . clone ( ) ) ;
726
745
self . tx_dependencies . init_tx_dependency ( self . tx_states . clone ( ) ) ;
727
746
self . metrics . parse_hints_time += start. elapsed ( ) . as_nanos ( ) as u64 ;
747
+ self . metrics . unknown_contract_tx_cnt += hints. unknown_contract_tx_cnt ;
748
+ self . metrics . raw_tx_cnt += hints. raw_tx_cnt ;
728
749
}
729
750
730
751
#[ fastrace:: trace]
@@ -754,7 +775,7 @@ where
754
775
let mut round = 0 ;
755
776
while round < MAX_NUM_ROUND {
756
777
if self . num_finality_txs < self . txs . len ( ) {
757
- self . partition_transactions ( ) ;
778
+ self . partition_transactions ( round ) ;
758
779
if self . num_partitions == 1 && !force_parallel {
759
780
break ;
760
781
}
0 commit comments