Skip to content

Commit 679bb12

Browse files
authored
poh: fix leader ticking race
1 parent e0150a6 commit 679bb12

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/discof/poh/fd_poh.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ fd_poh_hashing_to_leader_slot( fd_poh_t const * poh ) {
256256
return hashing && poh->slot<poh->next_leader_slot;
257257
}
258258

259+
int
260+
fd_poh_must_tick( fd_poh_t const * poh ) {
261+
return poh->state==STATE_LEADER && (poh->hashcnt%poh->hashcnt_per_tick)==(poh->hashcnt_per_tick-1UL);
262+
}
263+
259264
void
260265
fd_poh_done_packing( fd_poh_t * poh,
261266
ulong microblocks_in_slot ) {
@@ -650,6 +655,7 @@ fd_poh1_mixin( fd_poh_t * poh,
650655
if( FD_UNLIKELY( slot!=poh->next_leader_slot || slot!=poh->slot ) ) {
651656
FD_LOG_ERR(( "packed too early or late slot=%lu, current_slot=%lu", slot, poh->slot ));
652657
}
658+
if( FD_UNLIKELY( (poh->hashcnt%poh->hashcnt_per_tick)==(poh->hashcnt_per_tick-1UL) ) ) FD_LOG_CRIT(( "a tick will be skipped due to hashcnt %lu hashcnt_per_tick %lu", poh->hashcnt, poh->hashcnt_per_tick ));
653659

654660
FD_TEST( poh->state==STATE_LEADER );
655661
FD_TEST( poh->microblocks_lower_bound<poh->max_microblocks_per_slot );

src/discof/poh/fd_poh.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ fd_poh_have_leader_bank( fd_poh_t const * poh );
483483
int
484484
fd_poh_hashing_to_leader_slot( fd_poh_t const * poh );
485485

486+
int
487+
fd_poh_must_tick( fd_poh_t const * poh );
488+
486489
void
487490
fd_poh_begin_leader( fd_poh_t * poh,
488491
ulong slot,

src/discof/poh/fd_poh_tile.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ after_credit( fd_poh_tile_t * ctx,
6767
int * opt_poll_in,
6868
int * charge_busy ) {
6969
ctx->idle_cnt++;
70-
if( FD_UNLIKELY( ctx->idle_cnt>=2UL*ctx->in_cnt ) ) {
70+
if( FD_LIKELY( ctx->idle_cnt>=2UL*ctx->in_cnt || fd_poh_must_tick( ctx->poh ) ) ) {
7171
/* We would like to fully drain input links to the best of our
7272
knowledge, before we spend cycles on hashing. That is, we would
7373
like to assert that all input links have stayed empty since the
@@ -77,7 +77,12 @@ after_credit( fd_poh_tile_t * ctx,
7777
in_cnt-1 in the subsequent input link shuffle. So strictly
7878
speaking we will need to have observed 2*in_cnt-1 consecutive
7979
empty in links to be able to assert that link L has been empty
80-
since the last time we polled it. */
80+
since the last time we polled it.
81+
82+
Except that when we are leader and the hashcnt is right before a
83+
tick boundary, poh must advance to the tick boundary and produce
84+
the tick. Otherwise, a tick will be skipped if a microblock
85+
mixin happens. */
8186
fd_poh_advance( ctx->poh, stem, opt_poll_in, charge_busy );
8287
ctx->idle_cnt = 0UL;
8388
}

0 commit comments

Comments
 (0)