Skip to content

Commit fb1f54e

Browse files
committed
forest: remove reachable children from requests list
1 parent 4c40782 commit fb1f54e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/discof/forest/fd_forest.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,17 @@ fd_forest_blk_insert( fd_forest_t * forest, ulong slot, ulong parent_slot ) {
660660
if( fd_forest_requests_ele_query( requests, &ancestor, NULL, reqspool ) ) has_requests_anc = 1;
661661
ancestor = fd_forest_pool_ele( pool, ancestor )->parent;
662662
}
663-
if( FD_UNLIKELY( !has_requests_anc ) ) requests_insert( forest, fd_forest_requests( forest ), fd_forest_reqslist( forest ), fd_forest_pool_idx( pool, ele ) );
663+
if( FD_UNLIKELY( !has_requests_anc ) ) {
664+
requests_insert( forest, fd_forest_requests( forest ), fd_forest_reqslist( forest ), fd_forest_pool_idx( pool, ele ) );
665+
/* we want to remove any children than are in the requests list. This isn't necessary during any regular boot.
666+
However if we are booting from very far behind (>30k slots), the requests list will be very large and in
667+
nearly reverse order. */
668+
fd_forest_blk_t * child = fd_forest_pool_ele( pool, ele->child );
669+
while( FD_LIKELY( child ) ) {
670+
requests_remove( forest, fd_forest_requests( forest ), fd_forest_reqslist( forest ), &forest->iter, fd_forest_pool_idx( pool, child ) );
671+
child = fd_forest_pool_ele( pool, child->sibling );
672+
}
673+
}
664674
if( FD_UNLIKELY( !has_consumed_anc ) ) consumed_insert( forest, fd_forest_pool_idx( pool, ele ) );
665675
}
666676
return ele;
@@ -1169,7 +1179,7 @@ orphaned_print( fd_forest_t const * forest,
11691179
return;
11701180
}
11711181

1172-
char new_prefix[512]; /* FIXME size this correctly */
1182+
char new_prefix[1024]; /* FIXME size this correctly */
11731183
new_prefix[0] = '\0'; /* first fork stays on the same line, no prefix */
11741184
while( curr ) {
11751185
if( fd_forest_pool_ele_const( pool, curr->sibling ) ) {

0 commit comments

Comments
 (0)