40
40
pubkey:: Pubkey ,
41
41
signature:: Signature ,
42
42
slot_hashes,
43
+ timing:: AtomicInterval ,
43
44
transaction:: Transaction ,
44
45
} ,
45
46
std:: {
@@ -182,6 +183,47 @@ impl BankSendVotesStats {
182
183
}
183
184
}
184
185
186
+ #[ derive( Default ) ]
187
+ struct VoteProcessingTiming {
188
+ gossip_txn_processing_time_us : u64 ,
189
+ gossip_slot_confirming_time_us : u64 ,
190
+ last_report : AtomicInterval ,
191
+ }
192
+
193
+ const VOTE_PROCESSING_REPORT_INTERVAL_MS : u64 = 1_000 ;
194
+
195
+ impl VoteProcessingTiming {
196
+ fn reset ( & mut self ) {
197
+ self . gossip_slot_confirming_time_us = 0 ;
198
+ self . gossip_slot_confirming_time_us = 0 ;
199
+ }
200
+
201
+ fn update ( & mut self , vote_txn_processing_time_us : u64 , vote_slot_confirming_time_us : u64 ) {
202
+ self . gossip_txn_processing_time_us += vote_txn_processing_time_us;
203
+ self . gossip_slot_confirming_time_us += vote_slot_confirming_time_us;
204
+
205
+ if self
206
+ . last_report
207
+ . should_update ( VOTE_PROCESSING_REPORT_INTERVAL_MS )
208
+ {
209
+ datapoint_info ! (
210
+ "vote-processing-timing" ,
211
+ (
212
+ "vote_txn_processing_us" ,
213
+ self . gossip_txn_processing_time_us as i64 ,
214
+ i64
215
+ ) ,
216
+ (
217
+ "slot_confirming_time_us" ,
218
+ self . gossip_slot_confirming_time_us as i64 ,
219
+ i64
220
+ ) ,
221
+ ) ;
222
+ self . reset ( ) ;
223
+ }
224
+ }
225
+ }
226
+
185
227
pub struct ClusterInfoVoteListener {
186
228
thread_hdls : Vec < JoinHandle < ( ) > > ,
187
229
}
@@ -450,6 +492,7 @@ impl ClusterInfoVoteListener {
450
492
OptimisticConfirmationVerifier :: new ( bank_forks. read ( ) . unwrap ( ) . root ( ) ) ;
451
493
let mut last_process_root = Instant :: now ( ) ;
452
494
let cluster_confirmed_slot_sender = Some ( cluster_confirmed_slot_sender) ;
495
+ let mut vote_processing_time = Some ( VoteProcessingTiming :: default ( ) ) ;
453
496
loop {
454
497
if exit. load ( Ordering :: Relaxed ) {
455
498
return Ok ( ( ) ) ;
@@ -480,6 +523,7 @@ impl ClusterInfoVoteListener {
480
523
& replay_votes_receiver,
481
524
& bank_notification_sender,
482
525
& cluster_confirmed_slot_sender,
526
+ & mut vote_processing_time,
483
527
) ;
484
528
match confirmed_slots {
485
529
Ok ( confirmed_slots) => {
@@ -519,9 +563,11 @@ impl ClusterInfoVoteListener {
519
563
replay_votes_receiver,
520
564
& None ,
521
565
& None ,
566
+ & mut None ,
522
567
)
523
568
}
524
569
570
+ #[ allow( clippy:: too_many_arguments) ]
525
571
fn listen_and_confirm_votes (
526
572
gossip_vote_txs_receiver : & VerifiedVoteTransactionsReceiver ,
527
573
vote_tracker : & VoteTracker ,
@@ -532,6 +578,7 @@ impl ClusterInfoVoteListener {
532
578
replay_votes_receiver : & ReplayVoteReceiver ,
533
579
bank_notification_sender : & Option < BankNotificationSender > ,
534
580
cluster_confirmed_slot_sender : & Option < GossipDuplicateConfirmedSlotsSender > ,
581
+ vote_processing_time : & mut Option < VoteProcessingTiming > ,
535
582
) -> Result < ThresholdConfirmedSlots > {
536
583
let mut sel = Select :: new ( ) ;
537
584
sel. recv ( gossip_vote_txs_receiver) ;
@@ -560,6 +607,7 @@ impl ClusterInfoVoteListener {
560
607
verified_vote_sender,
561
608
bank_notification_sender,
562
609
cluster_confirmed_slot_sender,
610
+ vote_processing_time,
563
611
) ) ;
564
612
}
565
613
remaining_wait_time = remaining_wait_time. saturating_sub ( start. elapsed ( ) ) ;
@@ -682,6 +730,7 @@ impl ClusterInfoVoteListener {
682
730
}
683
731
}
684
732
733
+ #[ allow( clippy:: too_many_arguments) ]
685
734
fn filter_and_confirm_with_new_votes (
686
735
vote_tracker : & VoteTracker ,
687
736
gossip_vote_txs : Vec < Transaction > ,
@@ -692,11 +741,13 @@ impl ClusterInfoVoteListener {
692
741
verified_vote_sender : & VerifiedVoteSender ,
693
742
bank_notification_sender : & Option < BankNotificationSender > ,
694
743
cluster_confirmed_slot_sender : & Option < GossipDuplicateConfirmedSlotsSender > ,
744
+ vote_processing_time : & mut Option < VoteProcessingTiming > ,
695
745
) -> ThresholdConfirmedSlots {
696
746
let mut diff: HashMap < Slot , HashMap < Pubkey , bool > > = HashMap :: new ( ) ;
697
747
let mut new_optimistic_confirmed_slots = vec ! [ ] ;
698
748
699
749
// Process votes from gossip and ReplayStage
750
+ let mut gossip_vote_txn_processing_time = Measure :: start ( "gossip_vote_processing_time" ) ;
700
751
let votes = gossip_vote_txs
701
752
. iter ( )
702
753
. filter_map ( vote_parser:: parse_vote_transaction)
@@ -719,8 +770,11 @@ impl ClusterInfoVoteListener {
719
770
cluster_confirmed_slot_sender,
720
771
) ;
721
772
}
773
+ gossip_vote_txn_processing_time. stop ( ) ;
774
+ let gossip_vote_txn_processing_time_us = gossip_vote_txn_processing_time. as_us ( ) ;
722
775
723
776
// Process all the slots accumulated from replay and gossip.
777
+ let mut gossip_vote_slot_confirming_time = Measure :: start ( "gossip_vote_slot_confirm_time" ) ;
724
778
for ( slot, mut slot_diff) in diff {
725
779
let slot_tracker = vote_tracker. get_or_insert_slot_tracker ( slot) ;
726
780
{
@@ -768,6 +822,16 @@ impl ClusterInfoVoteListener {
768
822
769
823
w_slot_tracker. gossip_only_stake += gossip_only_stake
770
824
}
825
+ gossip_vote_slot_confirming_time. stop ( ) ;
826
+ let gossip_vote_slot_confirming_time_us = gossip_vote_slot_confirming_time. as_us ( ) ;
827
+
828
+ match vote_processing_time {
829
+ Some ( ref mut vote_processing_time) => vote_processing_time. update (
830
+ gossip_vote_txn_processing_time_us,
831
+ gossip_vote_slot_confirming_time_us,
832
+ ) ,
833
+ None => { }
834
+ }
771
835
new_optimistic_confirmed_slots
772
836
}
773
837
@@ -949,6 +1013,7 @@ mod tests {
949
1013
& replay_votes_receiver,
950
1014
& None ,
951
1015
& None ,
1016
+ & mut None ,
952
1017
)
953
1018
. unwrap ( ) ;
954
1019
@@ -980,6 +1045,7 @@ mod tests {
980
1045
& replay_votes_receiver,
981
1046
& None ,
982
1047
& None ,
1048
+ & mut None ,
983
1049
)
984
1050
. unwrap ( ) ;
985
1051
@@ -1062,6 +1128,7 @@ mod tests {
1062
1128
& replay_votes_receiver,
1063
1129
& None ,
1064
1130
& None ,
1131
+ & mut None ,
1065
1132
)
1066
1133
. unwrap ( ) ;
1067
1134
@@ -1219,6 +1286,7 @@ mod tests {
1219
1286
& replay_votes_receiver,
1220
1287
& None ,
1221
1288
& None ,
1289
+ & mut None ,
1222
1290
)
1223
1291
. unwrap ( ) ;
1224
1292
@@ -1319,6 +1387,7 @@ mod tests {
1319
1387
& replay_votes_receiver,
1320
1388
& None ,
1321
1389
& None ,
1390
+ & mut None ,
1322
1391
) ;
1323
1392
}
1324
1393
let slot_vote_tracker = vote_tracker. get_slot_vote_tracker ( vote_slot) . unwrap ( ) ;
@@ -1409,6 +1478,7 @@ mod tests {
1409
1478
& verified_vote_sender,
1410
1479
& None ,
1411
1480
& None ,
1481
+ & mut None ,
1412
1482
) ;
1413
1483
1414
1484
// Setup next epoch
@@ -1455,6 +1525,7 @@ mod tests {
1455
1525
& verified_vote_sender,
1456
1526
& None ,
1457
1527
& None ,
1528
+ & mut None ,
1458
1529
) ;
1459
1530
}
1460
1531
0 commit comments