Skip to content

Commit 56d15ad

Browse files
authored
bank, sched: aggressively mark banks dead and more debug logging
1 parent c63c875 commit 56d15ad

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/discof/replay/fd_sched.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ fd_sched_task_done( fd_sched_t * sched, ulong task_type, ulong txn_idx, ulong ex
913913
FD_LOG_CRIT(( "invariant violation: active block shouldn't be dying, bank_idx %lu, slot %lu, parent slot %lu",
914914
bank_idx, block->slot, block->parent_slot ));
915915
}
916+
FD_LOG_DEBUG(( "dying block %lu drained", block->slot ));
916917
subtree_abandon( sched, block );
917918
return;
918919
}
@@ -948,6 +949,7 @@ fd_sched_block_abandon( fd_sched_t * sched, ulong bank_idx ) {
948949
subtree_abandon( sched, block );
949950

950951
/* Reset the active block. */
952+
FD_LOG_DEBUG(( "reset active_bank_idx %lu", sched->active_bank_idx ));
951953
sched->active_bank_idx = ULONG_MAX;
952954
sched->metrics->deactivate_abandoned_cnt++;
953955
FD_LOG_INFO(( "block %lu abandoned", block->slot ));
@@ -1115,6 +1117,7 @@ fd_sched_root_notify( fd_sched_t * sched, ulong root_idx ) {
11151117
rooted_child_block = child;
11161118
} else {
11171119
/* This is a minority fork. */
1120+
FD_LOG_DEBUG(( "abandoning minority fork on block %lu", child->slot ));
11181121
subtree_abandon( sched, child );
11191122
}
11201123
child_idx = child->sibling_idx;
@@ -1475,8 +1478,9 @@ subtree_abandon( fd_sched_t * sched, fd_sched_block_t * block ) {
14751478
!block->staged || /* parent is in the dispatcher and staged but this block is unstaged */
14761479
block->staging_lane!=parent->staging_lane; /* this block is on a different staging lane than its parent */
14771480

1478-
if( FD_UNLIKELY( in_order && block->staged && sched->active_bank_idx==sched->staged_head_bank_idx[ block->staging_lane ] ) ) {
1481+
if( FD_UNLIKELY( in_order && block->staged && sched->active_bank_idx==sched->staged_head_bank_idx[ block->staging_lane ] && sched->active_bank_idx!=ULONG_MAX ) ) {
14791482
FD_TEST( block_pool_ele( sched, sched->active_bank_idx )==block );
1483+
FD_LOG_DEBUG(( "reset active_bank_idx %lu", sched->active_bank_idx ));
14801484
sched->active_bank_idx = ULONG_MAX;
14811485
}
14821486

@@ -1544,6 +1548,7 @@ maybe_switch_block( fd_sched_t * sched, ulong bank_idx ) {
15441548
if( FD_UNLIKELY( !block_is_activatable( child ) ) ) {
15451549
/* ... but the child is not activatable, likely because
15461550
there are no transactions available yet. */
1551+
FD_LOG_DEBUG(( "reset active_bank_idx %lu", sched->active_bank_idx ));
15471552
sched->active_bank_idx = ULONG_MAX;
15481553
sched->metrics->deactivate_no_txn_cnt++;
15491554
try_activate_block( sched );
@@ -1562,6 +1567,7 @@ maybe_switch_block( fd_sched_t * sched, ulong bank_idx ) {
15621567
} else {
15631568
/* ... but the child block is considered dead, likely because
15641569
the parser considers it invalid. */
1570+
FD_LOG_INFO(( "child block %lu is already dead", child->slot ));
15651571
subtree_abandon( sched, child );
15661572
break;
15671573
}
@@ -1574,6 +1580,7 @@ maybe_switch_block( fd_sched_t * sched, ulong bank_idx ) {
15741580
sched->staged_head_bank_idx[ block->staging_lane ] = ULONG_MAX;
15751581

15761582
/* Reset the active block. */
1583+
FD_LOG_DEBUG(( "reset active_bank_idx %lu", sched->active_bank_idx ));
15771584
sched->active_bank_idx = ULONG_MAX;
15781585
sched->metrics->deactivate_no_child_cnt++;
15791586
try_activate_block( sched );
@@ -1582,6 +1589,7 @@ maybe_switch_block( fd_sched_t * sched, ulong bank_idx ) {
15821589
are just not getting FEC sets for it fast enough. This could
15831590
happen when the network path is congested, or when the leader
15841591
simply went down. Reset the active block. */
1592+
FD_LOG_DEBUG(( "reset active_bank_idx %lu", sched->active_bank_idx ));
15851593
sched->active_bank_idx = ULONG_MAX;
15861594
sched->metrics->deactivate_no_txn_cnt++;
15871595
try_activate_block( sched );

src/flamenco/runtime/fd_bank.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,30 @@ fd_banks_advance_root_prepare( fd_banks_t * banks,
985985
curr = fd_banks_pool_ele( bank_pool, curr->parent_idx );
986986
}
987987

988-
ulong advance_candidate_idx = prev->idx;
989-
990988
/* If we didn't reach the old root or there is no parent, target is
991989
not a descendant. */
992990
if( FD_UNLIKELY( !curr || prev->parent_idx!=root->idx ) ) {
993991
FD_LOG_CRIT(( "invariant violation: target bank_idx %lu is not a direct descendant of root bank_idx %lu %lu %lu", target_bank_idx, root->idx, prev->idx, prev->parent_idx ));
994992
}
995993

994+
curr = root;
995+
while( curr && (curr->flags&FD_BANK_FLAGS_ROOTED) && curr!=target_bank ) { /* curr!=target_bank to avoid abandoning good forks. */
996+
fd_bank_t * rooted_child = NULL;
997+
ulong child_idx = curr->child_idx;
998+
while( child_idx!=fd_banks_pool_idx_null( bank_pool ) ) {
999+
fd_bank_t * child_bank = fd_banks_pool_ele( bank_pool, child_idx );
1000+
if( child_bank->flags&FD_BANK_FLAGS_ROOTED ) {
1001+
rooted_child = child_bank;
1002+
} else {
1003+
/* This is a minority fork. */
1004+
FD_LOG_DEBUG(( "abandoning minority fork on bank idx %lu", child_bank->idx ));
1005+
fd_banks_subtree_mark_dead( bank_pool, child_bank );
1006+
}
1007+
child_idx = child_bank->sibling_idx;
1008+
}
1009+
curr = rooted_child;
1010+
}
1011+
9961012
/* We should mark the old root bank as dead. */
9971013
root->flags |= FD_BANK_FLAGS_DEAD;
9981014

@@ -1001,11 +1017,11 @@ fd_banks_advance_root_prepare( fd_banks_t * banks,
10011017
potential new root are eligible for pruning. Each of the sibling
10021018
subtrees can be pruned if the subtrees have no active references on
10031019
their bank. */
1020+
ulong advance_candidate_idx = prev->idx;
10041021
ulong child_idx = root->child_idx;
10051022
while( child_idx!=fd_banks_pool_idx_null( bank_pool ) ) {
10061023
fd_bank_t * child_bank = fd_banks_pool_ele( bank_pool, child_idx );
10071024
if( child_idx!=advance_candidate_idx ) {
1008-
fd_banks_subtree_mark_dead( bank_pool, child_bank );
10091025
if( !fd_banks_subtree_can_be_pruned( bank_pool, child_bank ) ) {
10101026
fd_rwlock_unread( &banks->rwlock );
10111027
return 0;

0 commit comments

Comments
 (0)