Skip to content

Commit f9ff20d

Browse files
committed
pack: pack is responsible for ending leader slots
In full Firedancer the bank forks objects are implicitly refcounted by the leader pipeline, so they are acquired by pack and released by poh, because of this pack must "flush" the pipeline and give poh a way to guarantee the bank fork is not in use when it releases, which it can do by exactly sequencing the done packing messaage (must arrive after the bank microblocks).
1 parent 028b4db commit f9ff20d

File tree

8 files changed

+169
-167
lines changed

8 files changed

+169
-167
lines changed

src/app/fdctl/topology.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fd_topo_initialize( config_t * config ) {
3434
fd_topob_wksp( topo, "dedup_resolv" );
3535
fd_topob_wksp( topo, "resolv_pack" );
3636
fd_topob_wksp( topo, "pack_bank" );
37+
fd_topob_wksp( topo, "pack_poh" );
3738
fd_topob_wksp( topo, "bank_pack" );
3839
fd_topob_wksp( topo, "bank_poh" );
3940
fd_topob_wksp( topo, "bank_busy" );
@@ -75,6 +76,7 @@ fd_topo_initialize( config_t * config ) {
7576
/* pack_bank is shared across all banks, so if one bank stalls due to complex transactions, the buffer neeeds to be large so that
7677
other banks can keep proceeding. */
7778
/**/ fd_topob_link( topo, "pack_bank", "pack_bank", 65536UL, USHORT_MAX, 1UL );
79+
/**/ fd_topob_link( topo, "pack_poh", "pack_poh", 128UL, sizeof(fd_done_packing_t), 1UL );
7880
FOR(bank_tile_cnt) fd_topob_link( topo, "bank_poh", "bank_poh", 16384UL, USHORT_MAX, 1UL );
7981
FOR(bank_tile_cnt) fd_topob_link( topo, "bank_pack", "bank_pack", 16384UL, USHORT_MAX, 3UL );
8082
/**/ fd_topob_link( topo, "poh_pack", "bank_poh", 128UL, sizeof(fd_became_leader_t), 1UL );
@@ -170,14 +172,15 @@ fd_topo_initialize( config_t * config ) {
170172
/**/ fd_topob_tile_in( topo, "pack", 0UL, "metric_in", "poh_pack", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
171173
/**/ fd_topob_tile_in( topo, "pack", 0UL, "metric_in", "executed_txn", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
172174
fd_topob_tile_out( topo, "pack", 0UL, "pack_bank", 0UL );
175+
fd_topob_tile_out( topo, "pack", 0UL, "pack_poh", 0UL );
173176
FOR(bank_tile_cnt) fd_topob_tile_in( topo, "bank", i, "metric_in", "pack_bank", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
174177
FOR(bank_tile_cnt) fd_topob_tile_out( topo, "bank", i, "bank_poh", i );
175178
FOR(bank_tile_cnt) fd_topob_tile_out( topo, "bank", i, "bank_pack", i );
176179
FOR(bank_tile_cnt) fd_topob_tile_in( topo, "poh", 0UL, "metric_in", "bank_poh", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
177180
if( FD_LIKELY( config->tiles.pack.use_consumed_cus ) )
178181
FOR(bank_tile_cnt) fd_topob_tile_in( topo, "pack", 0UL, "metric_in", "bank_pack", i, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
179182
/**/ fd_topob_tile_in( topo, "poh", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
180-
/**/ fd_topob_tile_in( topo, "poh", 0UL, "metric_in", "pack_bank", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
183+
/**/ fd_topob_tile_in( topo, "poh", 0UL, "metric_in", "pack_poh", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
181184
/**/ fd_topob_tile_out( topo, "poh", 0UL, "poh_shred", 0UL );
182185
/**/ fd_topob_tile_out( topo, "poh", 0UL, "poh_pack", 0UL );
183186
FOR(shred_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
@@ -250,6 +253,7 @@ fd_topo_initialize( config_t * config ) {
250253
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "plugin_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
251254
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "poh_pack", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
252255
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "pack_bank", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
256+
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "pack_poh", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
253257
FOR(bank_tile_cnt) fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "bank_poh", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
254258
}
255259

src/disco/fd_disco_base.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
#define POH_PKT_TYPE_MICROBLOCK (0UL)
1919
#define POH_PKT_TYPE_BECAME_LEADER (1UL)
20-
#define POH_PKT_TYPE_DONE_PACKING (2UL)
21-
#define POH_PKT_TYPE_FEAT_ACT_SLOT (3UL)
20+
#define POH_PKT_TYPE_FEAT_ACT_SLOT (2UL)
2221

2322
#define REPLAY_FLAG_FINISHED_BLOCK (0x01UL)
2423
#define REPLAY_FLAG_PACKED_MICROBLOCK (0x02UL)
@@ -119,12 +118,12 @@ FD_FN_CONST static inline ulong fd_disco_poh_sig_bank_tile( ulong sig ) { return
119118

120119
FD_FN_CONST static inline ulong
121120
fd_disco_bank_sig( ulong slot,
122-
ulong microblock_idx ) {
123-
return (slot << 32) | microblock_idx;
121+
ulong pack_idx ) {
122+
return (slot << 32) | pack_idx;
124123
}
125124

126125
FD_FN_CONST static inline ulong fd_disco_bank_sig_slot( ulong sig ) { return (sig >> 32); }
127-
FD_FN_CONST static inline ulong fd_disco_bank_sig_microblock_idx( ulong sig ) { return sig & 0xFFFFFFFFUL; }
126+
FD_FN_CONST static inline ulong fd_disco_bank_sig_pack_idx( ulong sig ) { return sig & 0xFFFFFFFFUL; }
128127

129128
/* TODO remove with store_int */
130129

src/disco/gui/fd_gui_tile.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ extern uint const fdctl_commit_ref;
4343
#define IN_KIND_PLUGIN (0UL)
4444
#define IN_KIND_POH_PACK (1UL)
4545
#define IN_KIND_PACK_BANK (2UL)
46-
#define IN_KIND_BANK_POH (3UL)
46+
#define IN_KIND_PACK_POH (3UL)
47+
#define IN_KIND_BANK_POH (4UL)
4748

4849
FD_IMPORT_BINARY( firedancer_svg, "book/public/fire.svg" );
4950

@@ -219,6 +220,8 @@ after_frag( fd_gui_ctx_t * ctx,
219220
FD_TEST( fd_disco_poh_sig_pkt_type( sig )==POH_PKT_TYPE_BECAME_LEADER );
220221
fd_became_leader_t * became_leader = (fd_became_leader_t *)ctx->buf;
221222
fd_gui_became_leader( ctx->gui, fd_frag_meta_ts_decomp( tspub, fd_tickcount() ), fd_disco_poh_sig_slot( sig ), became_leader->slot_start_ns, became_leader->slot_end_ns, became_leader->limits.slot_max_cost, became_leader->max_microblocks_in_slot );
223+
} else if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_PACK_POH ) ) {
224+
fd_gui_unbecame_leader( ctx->gui, fd_frag_meta_ts_decomp( tspub, fd_tickcount() ), fd_disco_poh_sig_slot( sig ), ((fd_done_packing_t *)ctx->buf)->microblocks_in_slot );
222225
} else if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_PACK_BANK ) ) {
223226
if( FD_LIKELY( fd_disco_poh_sig_pkt_type( sig )==POH_PKT_TYPE_MICROBLOCK ) ) {
224227
fd_microblock_bank_trailer_t * trailer = (fd_microblock_bank_trailer_t *)( ctx->buf+sz-sizeof(fd_microblock_bank_trailer_t) );
@@ -229,8 +232,6 @@ after_frag( fd_gui_ctx_t * ctx,
229232
(sz-sizeof( fd_microblock_bank_trailer_t ))/sizeof( fd_txn_p_t ),
230233
(uint)trailer->microblock_idx,
231234
trailer->pack_txn_idx );
232-
} else if( FD_LIKELY( fd_disco_poh_sig_pkt_type( sig )==POH_PKT_TYPE_DONE_PACKING ) ) {
233-
fd_gui_unbecame_leader( ctx->gui, fd_frag_meta_ts_decomp( tspub, fd_tickcount() ), fd_disco_poh_sig_slot( sig ), ((fd_done_packing_t *)ctx->buf)->microblocks_in_slot );
234235
} else {
235236
FD_LOG_ERR(( "unexpected poh packet type %lu", fd_disco_poh_sig_pkt_type( sig ) ));
236237
}
@@ -510,6 +511,7 @@ unprivileged_init( fd_topo_t * topo,
510511
if( FD_LIKELY( !strcmp( link->name, "plugin_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_PLUGIN;
511512
else if( FD_LIKELY( !strcmp( link->name, "poh_pack" ) ) ) ctx->in_kind[ i ] = IN_KIND_POH_PACK;
512513
else if( FD_LIKELY( !strcmp( link->name, "pack_bank" ) ) ) ctx->in_kind[ i ] = IN_KIND_PACK_BANK;
514+
else if( FD_LIKELY( !strcmp( link->name, "pack_poh" ) ) ) ctx->in_kind[ i ] = IN_KIND_PACK_POH;
513515
else if( FD_LIKELY( !strcmp( link->name, "bank_poh" ) ) ) ctx->in_kind[ i ] = IN_KIND_BANK_POH;
514516
else FD_LOG_ERR(( "gui tile has unexpected input link %lu %s", i, link->name ));
515517

0 commit comments

Comments
 (0)