Skip to content

Commit 2fafbb9

Browse files
committed
discoh: turbine fanout experiments
1 parent 5eeb524 commit 2fafbb9

File tree

9 files changed

+251
-130
lines changed

9 files changed

+251
-130
lines changed

src/app/fdctl/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fd_topo_initialize( config_t * config ) {
7878
FOR(bank_tile_cnt) fd_topob_link( topo, "bank_poh", "bank_poh", 16384UL, USHORT_MAX, 1UL );
7979
FOR(bank_tile_cnt) fd_topob_link( topo, "bank_pack", "bank_pack", 16384UL, USHORT_MAX, 3UL );
8080
/**/ fd_topob_link( topo, "poh_pack", "bank_poh", 128UL, sizeof(fd_became_leader_t), 1UL );
81-
/**/ fd_topob_link( topo, "poh_shred", "poh_shred", 16384UL, USHORT_MAX, 1UL );
81+
/**/ fd_topob_link( topo, "poh_shred", "poh_shred", 16384UL, USHORT_MAX, 2UL );
8282
/**/ fd_topob_link( topo, "crds_shred", "poh_shred", 128UL, 8UL + 40200UL * 38UL, 1UL );
8383
/**/ fd_topob_link( topo, "replay_resol", "bank_poh", 128UL, sizeof(fd_completed_bank_t), 1UL );
8484
/* See long comment in fd_shred.c for an explanation about the size of this dcache. */

src/disco/fd_disco_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define POH_PKT_TYPE_MICROBLOCK (0UL)
1818
#define POH_PKT_TYPE_BECAME_LEADER (1UL)
1919
#define POH_PKT_TYPE_DONE_PACKING (2UL)
20+
#define POH_PKT_TYPE_FEAT_ACT_SLOT (3UL)
2021

2122
#define REPLAY_FLAG_FINISHED_BLOCK (0x01UL)
2223
#define REPLAY_FLAG_PACKED_MICROBLOCK (0x02UL)

src/disco/shred/fd_shred_dest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ fd_shred_dest_compute_first( fd_shred_dest_t * sdest,
286286
for( ulong i=0UL; i<shred_cnt; i++ ) {
287287
fd_wsample_seed_rng( fd_wsample_get_rng( sdest->staked ), dest_hash_outputs[ i ] );
288288
/* Map FD_WSAMPLE_INDETERMINATE to FD_SHRED_DEST_NO_DEST */
289-
if( FD_LIKELY( any_staked_candidates ) ) out[i] = (ushort)fd_ulong_min( fd_wsample_sample( sdest->staked ), FD_SHRED_DEST_NO_DEST );
290-
else out[i] = (ushort)sample_unstaked_noprepare( sdest, sdest->source_validator_orig_idx );
289+
if( FD_LIKELY( any_staked_candidates ) ) out[i] = (fd_shred_dest_idx_t)fd_ulong_min( fd_wsample_sample( sdest->staked ), FD_SHRED_DEST_NO_DEST );
290+
else out[i] = (fd_shred_dest_idx_t)sample_unstaked_noprepare( sdest, sdest->source_validator_orig_idx );
291291
}
292292
fd_wsample_restore_all( sdest->staked );
293293

src/disco/shred/fd_shred_dest.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010
to compute the destination of a specific shred for the leader and
1111
non-leader. This is where the Turbine tree logic is implemented. */
1212

13-
/* For a given FEC, we might need to produce 200 destinations for each
14-
of 134 shreds, which is a lot of destinations! Full destination
13+
/* For a given FEC, we might need to produce "fanout" destinations for
14+
each of 134 shreds, which is a lot of destinations! Full destination
1515
information (ip, port, mac) is 12 B. A pointer is 8 B, but an index
16-
can be as small as 2 B, since currently Turbine doesn't work with
17-
more than fanout^2 nodes which is less than USHORT_MAX. Thus, we go
18-
with the index, which can cheaply be mapped to the full information
19-
using fd_shred_dest_idx_to_dest below. */
20-
typedef ushort fd_shred_dest_idx_t;
16+
can be as small as 4 B, since currently Turbine doesn't work with
17+
more than fanout^2 nodes, which is less than UINT_MAX for a maximum
18+
fanout of 1536 (the fanout is dependent on feature activation). Thus,
19+
we go with the index, which can cheaply be mapped to the full
20+
information using fd_shred_dest_idx_to_dest below. */
21+
typedef uint fd_shred_dest_idx_t;
2122

2223

2324
#define FD_SHRED_DEST_MAX_SHRED_CNT (134UL) /* DATA_SHREDS_MAX+PARITY_SHREDS_MAX */
24-
#define FD_SHRED_DEST_NO_DEST (USHORT_MAX)
25+
#define FD_SHRED_DEST_NO_DEST (UINT_MAX)
26+
#define FD_SHRED_DEST_MAX_FANOUT (1536UL)
2527

2628
/* fd_shred_dest_weighted_t specifies a destination to which a shred might be
2729
sent. The information comes from Gossip typically. */

src/disco/shred/fd_shred_tile.c

Lines changed: 173 additions & 114 deletions
Large diffs are not rendered by default.

src/disco/shred/fd_shredder.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626
typedef void (fd_shredder_sign_fn)( void * ctx, uchar * sig, uchar const * merkle_root );
2727

2828

29+
#define FD_SHRED_FEATURES_ACTIVATION_SLOT_CNT (4UL)
30+
#define FD_SHRED_FEATURES_ACTIVATION_SLOT_SZ (8UL)
31+
#define FD_SHRED_FEATURES_ACTIVATION_SLOT_DISABLED (ULONG_MAX)
32+
33+
union fd_shred_features_activation_private {
34+
/* slots for features of interest - update cnt as needed in the future. */
35+
ulong slots[ FD_SHRED_FEATURES_ACTIVATION_SLOT_CNT ];
36+
struct {
37+
/* 0 */ ulong disable_turbine_fanout_experiments;
38+
/* 1 */ ulong enable_turbine_extended_fanout_experiments;
39+
/* 2 */ ulong enable_chained_merkle_shreds;
40+
/* 3 */ ulong drop_unchained_merkle_shreds;
41+
};
42+
};
43+
typedef union fd_shred_features_activation_private fd_shred_features_activation_t;
44+
2945

3046
static ulong const fd_shredder_data_to_parity_cnt[ 33UL ] = {
3147
0UL, 17UL, 18UL, 19UL, 19UL, 20UL, 21UL, 21UL,

src/disco/shred/test_shred_dest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test_distribution_is_tree( fd_shred_dest_weighted_t const * info, ulong cnt, fd_
156156
}
157157

158158
for( ulong i=0; i<dest_cnt; i++ ) {
159-
ushort child = out[i];
159+
fd_shred_dest_idx_t child = out[i];
160160
if( FD_LIKELY( child != FD_SHRED_DEST_NO_DEST ) ) {
161161
FD_TEST( !hit[child] );
162162
hit[child] = 1;

src/discoh/poh/fd_poh_tile.c

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ typedef struct {
542542
fd_histf_t first_microblock_delay[ 1 ];
543543
fd_histf_t slot_done_delay[ 1 ];
544544
fd_histf_t bundle_init_delay[ 1 ];
545+
546+
ulong features_activation_avail;
547+
fd_shred_features_activation_t features_activation[1];
545548
} fd_poh_ctx_t;
546549

547550
/* The PoH recorder is implemented in Firedancer but for now needs to
@@ -1224,7 +1227,10 @@ no_longer_leader( fd_poh_ctx_t * ctx ) {
12241227
CALLED_FROM_RUST void
12251228
fd_ext_poh_reset( ulong completed_bank_slot, /* The slot that successfully produced a block */
12261229
uchar const * reset_blockhash, /* The hash of the last tick in the produced block */
1227-
ulong hashcnt_per_tick /* The hashcnt per tick of the bank that completed */ ) {
1230+
ulong hashcnt_per_tick, /* The hashcnt per tick of the bank that completed */
1231+
uchar const * parent_block_id, /* The block id of the parent block */
1232+
ulong const * features_activation /* The activation slot of shred-tile features */ ) {
1233+
(void)parent_block_id;
12281234
fd_poh_ctx_t * ctx = fd_ext_poh_write_lock();
12291235

12301236
ulong slot_before_reset = ctx->slot;
@@ -1316,6 +1322,16 @@ fd_ext_poh_reset( ulong completed_bank_slot, /* The slot that successful
13161322
if( FD_UNLIKELY( leader_before_reset ) ) publish_plugin_slot_end( ctx, slot_before_reset, ctx->cus_used );
13171323
}
13181324

1325+
/* There is a subset of FD_SHRED_FEATURES_ACTIVATION_... slots that
1326+
the shred tile needs to be aware of. Since their computation
1327+
requires the bank, we are forced (so far) to receive them here
1328+
from the Rust side, before forwarding them to the shred tile as
1329+
POH_PKT_TYPE_FEAT_ACT_SLOT. This is not elegant, and it should
1330+
be revised in the future (TODO), but it provides a "temporary"
1331+
working solution to handle features activation. */
1332+
fd_memcpy( ctx->features_activation->slots, features_activation, sizeof(fd_shred_features_activation_t) );
1333+
ctx->features_activation_avail = 1UL;
1334+
13191335
fd_ext_poh_write_unlock();
13201336
}
13211337

@@ -1403,6 +1419,21 @@ publish_tick( fd_poh_ctx_t * ctx,
14031419
}
14041420
}
14051421

1422+
static inline void
1423+
publish_features_activation( fd_poh_ctx_t * ctx,
1424+
fd_stem_context_t * stem ) {
1425+
uchar * dst = (uchar *)fd_chunk_to_laddr( ctx->shred_out->mem, ctx->shred_out->chunk );
1426+
fd_shred_features_activation_t * act_data = (fd_shred_features_activation_t *)dst;
1427+
fd_memcpy( act_data, ctx->features_activation, sizeof(fd_shred_features_activation_t) );
1428+
1429+
ulong tspub = (ulong)fd_frag_meta_ts_comp( fd_tickcount() );
1430+
ulong sz = sizeof(fd_shred_features_activation_t);
1431+
ulong sig = fd_disco_poh_sig( ctx->slot, POH_PKT_TYPE_FEAT_ACT_SLOT, 0UL );
1432+
fd_stem_publish( stem, ctx->shred_out->idx, sig, ctx->shred_out->chunk, sz, 0UL, 0UL, tspub );
1433+
ctx->shred_seq = stem->seqs[ ctx->shred_out->idx ];
1434+
ctx->shred_out->chunk = fd_dcache_compact_next( ctx->shred_out->chunk, sz, ctx->shred_out->chunk0, ctx->shred_out->wmark );
1435+
}
1436+
14061437
static inline void
14071438
after_credit( fd_poh_ctx_t * ctx,
14081439
fd_stem_context_t * stem,
@@ -1426,6 +1457,14 @@ after_credit( fd_poh_ctx_t * ctx,
14261457
}
14271458
FD_COMPILER_MFENCE();
14281459

1460+
if( FD_UNLIKELY( ctx->features_activation_avail ) ) {
1461+
/* If we have received an update on features_activation, then
1462+
forward them to the shred tile. In principle, this should
1463+
happen at most once per slot. */
1464+
publish_features_activation( ctx, stem );
1465+
ctx->features_activation_avail = 0UL;
1466+
}
1467+
14291468
int is_leader = ctx->next_leader_slot!=ULONG_MAX && ctx->slot>=ctx->next_leader_slot;
14301469
if( FD_UNLIKELY( is_leader && !ctx->current_leader_bank ) ) {
14311470
/* If we are the leader, but we didn't yet learn what the leader
@@ -2272,14 +2311,18 @@ unprivileged_init( fd_topo_t * topo,
22722311
*ctx->plugin_out = out1( topo, tile, "poh_plugin" );
22732312
}
22742313

2314+
ctx->features_activation_avail = 0UL;
2315+
for( ulong i=0UL; i<FD_SHRED_FEATURES_ACTIVATION_SLOT_CNT; i++ )
2316+
ctx->features_activation->slots[i] = FD_SHRED_FEATURES_ACTIVATION_SLOT_DISABLED;
2317+
22752318
ulong scratch_top = FD_SCRATCH_ALLOC_FINI( l, 1UL );
22762319
if( FD_UNLIKELY( scratch_top > (ulong)scratch + scratch_footprint( tile ) ) )
22772320
FD_LOG_ERR(( "scratch overflow %lu %lu %lu", scratch_top - (ulong)scratch - scratch_footprint( tile ), scratch_top, (ulong)scratch + scratch_footprint( tile ) ));
22782321
}
22792322

22802323
/* One tick, one microblock, one plugin slot end, one plugin slot start,
2281-
and one leader update. */
2282-
#define STEM_BURST (5UL)
2324+
one leader update, and one features activation. */
2325+
#define STEM_BURST (6UL)
22832326

22842327
/* See explanation in fd_pack */
22852328
#define STEM_LAZY (128L*3000L)

0 commit comments

Comments
 (0)