@@ -45,6 +45,16 @@ pub struct SnapshotConfig {
45
45
pub maximum_snapshots_to_retain : usize ,
46
46
}
47
47
48
+ struct SetRootTimings {
49
+ total_banks : i64 ,
50
+ total_squash_cache_ms : i64 ,
51
+ total_squash_accounts_ms : i64 ,
52
+ total_snapshot_ms : i64 ,
53
+ tx_count : i64 ,
54
+ prune_non_rooted_ms : i64 ,
55
+ drop_parent_banks_ms : i64 ,
56
+ }
57
+
48
58
pub struct BankForks {
49
59
banks : HashMap < Slot , Arc < Bank > > ,
50
60
descendants : HashMap < Slot , HashSet < Slot > > ,
@@ -198,15 +208,14 @@ impl BankForks {
198
208
self [ self . highest_slot ( ) ] . clone ( )
199
209
}
200
210
201
- pub fn set_root (
211
+ fn do_set_root_return_metrics (
202
212
& mut self ,
203
213
root : Slot ,
204
214
accounts_background_request_sender : & AbsRequestSender ,
205
215
highest_confirmed_root : Option < Slot > ,
206
- ) {
216
+ ) -> SetRootTimings {
207
217
let old_epoch = self . root_bank ( ) . epoch ( ) ;
208
218
self . root = root;
209
- let set_root_start = Instant :: now ( ) ;
210
219
let root_bank = self
211
220
. banks
212
221
. get ( & root)
@@ -215,9 +224,9 @@ impl BankForks {
215
224
if old_epoch != new_epoch {
216
225
info ! (
217
226
"Root entering
218
- epoch: {},
219
- next_epoch_start_slot: {},
220
- epoch_stakes: {:#?}" ,
227
+ epoch: {},
228
+ next_epoch_start_slot: {},
229
+ epoch_stakes: {:#?}" ,
221
230
new_epoch,
222
231
root_bank
223
232
. epoch_schedule( )
@@ -249,8 +258,8 @@ impl BankForks {
249
258
{
250
259
self . last_accounts_hash_slot = bank_slot;
251
260
let squash_timing = bank. squash ( ) ;
252
- total_squash_accounts_ms += squash_timing. squash_accounts_ms ;
253
- total_squash_cache_ms += squash_timing. squash_cache_ms ;
261
+ total_squash_accounts_ms += squash_timing. squash_accounts_ms as i64 ;
262
+ total_squash_cache_ms += squash_timing. squash_cache_ms as i64 ;
254
263
is_root_bank_squashed = bank_slot == root;
255
264
256
265
let mut snapshot_time = Measure :: start ( "squash::snapshot_time" ) ;
@@ -275,20 +284,47 @@ impl BankForks {
275
284
}
276
285
}
277
286
snapshot_time. stop ( ) ;
278
- total_snapshot_ms += snapshot_time. as_ms ( ) ;
287
+ total_snapshot_ms += snapshot_time. as_ms ( ) as i64 ;
279
288
break ;
280
289
}
281
290
}
282
291
if !is_root_bank_squashed {
283
292
let squash_timing = root_bank. squash ( ) ;
284
- total_squash_accounts_ms += squash_timing. squash_accounts_ms ;
285
- total_squash_cache_ms += squash_timing. squash_cache_ms ;
293
+ total_squash_accounts_ms += squash_timing. squash_accounts_ms as i64 ;
294
+ total_squash_cache_ms += squash_timing. squash_cache_ms as i64 ;
286
295
}
287
296
let new_tx_count = root_bank. transaction_count ( ) ;
288
297
let mut prune_time = Measure :: start ( "set_root::prune" ) ;
289
298
self . prune_non_rooted ( root, highest_confirmed_root) ;
290
299
prune_time. stop ( ) ;
291
300
301
+ let mut drop_parent_banks_time = Measure :: start ( "set_root::drop_banks" ) ;
302
+ drop ( parents) ;
303
+ drop_parent_banks_time. stop ( ) ;
304
+
305
+ SetRootTimings {
306
+ total_banks : total_banks as i64 ,
307
+ total_squash_cache_ms,
308
+ total_squash_accounts_ms,
309
+ total_snapshot_ms,
310
+ tx_count : ( new_tx_count - root_tx_count) as i64 ,
311
+ prune_non_rooted_ms : prune_time. as_ms ( ) as i64 ,
312
+ drop_parent_banks_ms : drop_parent_banks_time. as_ms ( ) as i64 ,
313
+ }
314
+ }
315
+
316
+ pub fn set_root (
317
+ & mut self ,
318
+ root : Slot ,
319
+ accounts_background_request_sender : & AbsRequestSender ,
320
+ highest_confirmed_root : Option < Slot > ,
321
+ ) {
322
+ let set_root_start = Instant :: now ( ) ;
323
+ let set_root_metrics = self . do_set_root_return_metrics (
324
+ root,
325
+ accounts_background_request_sender,
326
+ highest_confirmed_root,
327
+ ) ;
292
328
datapoint_info ! (
293
329
"bank-forks_set_root" ,
294
330
(
@@ -297,12 +333,29 @@ impl BankForks {
297
333
i64
298
334
) ,
299
335
( "slot" , root, i64 ) ,
300
- ( "total_banks" , total_banks, i64 ) ,
301
- ( "total_squash_cache_ms" , total_squash_cache_ms, i64 ) ,
302
- ( "total_squash_accounts_ms" , total_squash_accounts_ms, i64 ) ,
303
- ( "total_snapshot_ms" , total_snapshot_ms, i64 ) ,
304
- ( "tx_count" , ( new_tx_count - root_tx_count) as usize , i64 ) ,
305
- ( "prune_non_rooted_ms" , prune_time. as_ms( ) , i64 ) ,
336
+ ( "total_banks" , set_root_metrics. total_banks, i64 ) ,
337
+ (
338
+ "total_squash_cache_ms" ,
339
+ set_root_metrics. total_squash_cache_ms,
340
+ i64
341
+ ) ,
342
+ (
343
+ "total_squash_accounts_ms" ,
344
+ set_root_metrics. total_squash_accounts_ms,
345
+ i64
346
+ ) ,
347
+ ( "total_snapshot_ms" , set_root_metrics. total_snapshot_ms, i64 ) ,
348
+ ( "tx_count" , set_root_metrics. tx_count, i64 ) ,
349
+ (
350
+ "prune_non_rooted_ms" ,
351
+ set_root_metrics. prune_non_rooted_ms,
352
+ i64
353
+ ) ,
354
+ (
355
+ "drop_parent_banks_ms" ,
356
+ set_root_metrics. drop_parent_banks_ms,
357
+ i64
358
+ ) ,
306
359
) ;
307
360
}
308
361
0 commit comments