Skip to content

Commit 93a3c72

Browse files
committed
firedancer-dev: repair profiler
1 parent 131b6de commit 93a3c72

File tree

10 files changed

+723
-21
lines changed

10 files changed

+723
-21
lines changed

src/app/firedancer-dev/Local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $(call add-objs,commands/dev,fd_firedancer_dev)
1414
$(call add-objs,commands/sim,fd_firedancer_dev)
1515
$(call add-objs,commands/backtest,fd_firedancer_dev)
1616
$(call add-objs,commands/snapshot_load,fd_firedancer_dev)
17+
$(call add-objs,commands/repair,fd_firedancer_dev)
1718

1819
$(call make-bin,firedancer-dev,main,fd_firedancer_dev fd_firedancer fddev_shared fdctl_shared fdctl_platform fd_discof fd_disco fd_choreo fd_flamenco fd_funk fd_quic fd_tls fd_reedsol fd_waltz fd_tango fd_ballet fd_util firedancer_version,$(SECP256K1_LIBS) $(ROCKSDB_LIBS) $(OPENSSL_LIBS))
1920

src/app/firedancer-dev/commands/repair.c

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

src/app/firedancer-dev/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ extern action_t fd_action_gossip;
185185
extern action_t fd_action_sim;
186186
extern action_t fd_action_backtest;
187187
extern action_t fd_action_snapshot_load;
188+
extern action_t fd_action_repair;
188189

189190
action_t * ACTIONS[] = {
190191
&fd_action_run,
@@ -213,6 +214,7 @@ action_t * ACTIONS[] = {
213214
&fd_action_sim,
214215
&fd_action_backtest,
215216
&fd_action_snapshot_load,
217+
&fd_action_repair,
216218
NULL,
217219
};
218220

src/app/firedancer/topology.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ fd_topo_initialize( config_t * config ) {
791791
fd_topob_wksp( topo, "repair_scap" );
792792
fd_topob_wksp( topo, "replay_scap" );
793793

794-
fd_topob_tile( topo, "scap", "scap", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 0 );
794+
fd_topo_tile_t * scap_tile = fd_topob_tile( topo, "scap", "scap", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 0 );
795795

796796
fd_topob_link( topo, "repair_scap", "repair_scap", 128UL, FD_SLICE_MAX_WITH_HEADERS, 1UL );
797797
fd_topob_link( topo, "replay_scap", "replay_scap", 128UL, sizeof(fd_hash_t)+sizeof(ulong), 1UL );
@@ -811,6 +811,11 @@ fd_topo_initialize( config_t * config ) {
811811

812812
fd_topob_tile_out( topo, "repair", 0UL, "repair_scap", 0UL );
813813
fd_topob_tile_out( topo, "replay", 0UL, "replay_scap", 0UL );
814+
815+
fd_topob_tile_uses( topo, scap_tile, root_slot_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
816+
fd_topob_tile_uses( topo, scap_tile, replay_manifest_dcache, FD_SHMEM_JOIN_MODE_READ_ONLY );
817+
fd_topob_tile_in( topo, "scap", 0UL, "metric_in", "snap_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
818+
/* No default fd_topob_tile_in connection to stake_out */
814819
}
815820

816821
fd_topob_wksp( topo, "replay_notif" );
@@ -1106,6 +1111,8 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
11061111
tile->shredcap.repair_intake_listen_port = config->tiles.repair.repair_intake_listen_port;
11071112
strncpy( tile->shredcap.folder_path, config->tiles.shredcap.folder_path, sizeof(tile->shredcap.folder_path) );
11081113
tile->shredcap.write_buffer_size = config->tiles.shredcap.write_buffer_size;
1114+
tile->shredcap.enable_publish_stake_weights = 0; /* this is not part of the config */
1115+
tile->shredcap.manifest_dcache_obj_id = fd_pod_query_ulong( config->topo.props, "manifest_dcache", ULONG_MAX );
11091116
} else {
11101117
return 0;
11111118
}

src/disco/topo/fd_topo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ struct fd_topo_tile {
451451
char folder_path[ PATH_MAX ];
452452
ushort repair_intake_listen_port;
453453
ulong write_buffer_size; /* Size of the write buffer for the capture tile */
454+
int enable_publish_stake_weights;
455+
ulong manifest_dcache_obj_id;
454456

455457
/* Set internally by the capture tile */
456458
int shreds_fd;

src/discof/forest/fd_forest.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,12 @@ ancestry_print3( fd_forest_t const * forest, fd_forest_ele_t const * ele, int sp
823823

824824
void
825825
fd_forest_ancestry_print( fd_forest_t const * forest ) {
826+
fflush(stdout);
826827
FD_LOG_NOTICE(("\n\n[Ancestry]\n\n" ) );
827828

828829
ancestry_print3( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root ), 0, "[", NULL, 0 );
829830
//ancestry_print( forest, fd_forest_pool_ele_const( fd_forest_pool_const( forest ), forest->root ), 0, "" );
830-
831+
fflush(stdout);
831832
}
832833

833834
void

src/discof/repair/fd_repair_tile.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ after_frag( fd_repair_tile_ctx_t * ctx,
842842
fd_fseq_update( ctx->turbine_slot, fd_ulong_max( shred->slot, fd_fseq_query( ctx->turbine_slot ) ) );
843843
if( FD_UNLIKELY( shred->slot <= fd_forest_root_slot( ctx->forest ) ) ) return; /* shred too old */
844844

845+
/* TODO add automated caught-up test */
845846

846847
/* Insert the shred sig (shared by all shred members in the FEC set)
847848
into the map. */
@@ -1075,6 +1076,7 @@ during_housekeeping( fd_repair_tile_ctx_t * ctx ) {
10751076
return;
10761077
}
10771078
}
1079+
10781080
static void
10791081
privileged_init( fd_topo_t * topo,
10801082
fd_topo_tile_t * tile ) {
@@ -1196,7 +1198,6 @@ unprivileged_init( fd_topo_t * topo,
11961198

11971199
/* Scratch mem setup */
11981200

1199-
ctx->blockstore = &ctx->blockstore_ljoin;
12001201
ctx->repair = FD_SCRATCH_ALLOC_APPEND( l, fd_repair_align(), fd_repair_footprint() );
12011202
ctx->forest = FD_SCRATCH_ALLOC_APPEND( l, fd_forest_align(), fd_forest_footprint( tile->repair.slot_max ) );
12021203
ctx->fec_sigs = FD_SCRATCH_ALLOC_APPEND( l, fd_fec_sig_align(), fd_fec_sig_footprint( 20 ) );
@@ -1237,17 +1238,20 @@ unprivileged_init( fd_topo_t * topo,
12371238
}
12381239

12391240
/* Blockstore setup */
1241+
ctx->blockstore = NULL;
12401242
ulong blockstore_obj_id = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "blockstore" );
1241-
FD_TEST( blockstore_obj_id!=ULONG_MAX );
1242-
ctx->blockstore_wksp = topo->workspaces[ topo->objs[ blockstore_obj_id ].wksp_id ].wksp;
1243-
1244-
if( ctx->blockstore_wksp==NULL ) {
1245-
FD_LOG_ERR(( "no blocktore workspace" ));
1243+
if( FD_UNLIKELY( blockstore_obj_id==ULONG_MAX ) ) {
1244+
FD_LOG_WARNING(( "no blockstore_obj_id" ));
1245+
} else {
1246+
ctx->blockstore_wksp = topo->workspaces[ topo->objs[ blockstore_obj_id ].wksp_id ].wksp;
1247+
if( FD_UNLIKELY( ctx->blockstore_wksp==NULL ) ) {
1248+
FD_LOG_WARNING(( "no blocktore workspace" ));
1249+
} else {
1250+
ctx->blockstore = fd_blockstore_join( &ctx->blockstore_ljoin, fd_topo_obj_laddr( topo, blockstore_obj_id ) );
1251+
FD_TEST( ctx->blockstore!=NULL );
1252+
}
12461253
}
12471254

1248-
ctx->blockstore = fd_blockstore_join( &ctx->blockstore_ljoin, fd_topo_obj_laddr( topo, blockstore_obj_id ) );
1249-
FD_TEST( ctx->blockstore!=NULL );
1250-
12511255
FD_LOG_NOTICE(( "repair starting" ));
12521256

12531257
/* Repair set up */

src/discof/replay/fd_exec.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ static inline ulong
1414
generate_stake_weight_msg( fd_exec_slot_ctx_t * slot_ctx,
1515
fd_spad_t * runtime_spad,
1616
ulong epoch,
17+
fd_vote_accounts_global_t const * vote_accounts,
1718
ulong * stake_weight_msg_out ) {
1819

1920
fd_stake_weight_msg_t * stake_weight_msg = (fd_stake_weight_msg_t *)fd_type_pun( stake_weight_msg_out );
2021
fd_stake_weight_t * stake_weights = (fd_stake_weight_t *)&stake_weight_msg_out[5];
21-
fd_vote_accounts_global_t const * vote_accounts = fd_bank_epoch_stakes_locking_query( slot_ctx->bank );
2222
ulong stake_weight_idx = fd_stake_weights_by_node( vote_accounts,
2323
stake_weights,
2424
runtime_spad );
25-
fd_bank_epoch_stakes_end_locking_query( slot_ctx->bank );
26-
2725
fd_epoch_schedule_t const * epoch_schedule = fd_bank_epoch_schedule_query( slot_ctx->bank );
2826

2927
stake_weight_msg->epoch = epoch;

src/discof/replay/fd_replay_tile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ publish_stake_weights( fd_replay_tile_ctx_t * ctx,
311311
if( epoch_stakes_root!=NULL ) {
312312
ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk );
313313
ulong epoch = fd_slot_to_leader_schedule_epoch( epoch_schedule, fd_bank_slot_get( slot_ctx->bank ) );
314-
ulong stake_weights_sz = generate_stake_weight_msg( slot_ctx, ctx->runtime_spad, epoch - 1, stake_weights_msg );
314+
ulong stake_weights_sz = generate_stake_weight_msg( slot_ctx, ctx->runtime_spad, epoch - 1, epoch_stakes, stake_weights_msg );
315315
ulong stake_weights_sig = 4UL;
316316
fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) );
317317
ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark );
@@ -326,7 +326,7 @@ publish_stake_weights( fd_replay_tile_ctx_t * ctx,
326326
if( next_epoch_stakes_root!=NULL ) {
327327
ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk );
328328
ulong epoch = fd_slot_to_leader_schedule_epoch( epoch_schedule, fd_bank_slot_get( slot_ctx->bank ) ); /* epoch */
329-
ulong stake_weights_sz = generate_stake_weight_msg( slot_ctx, ctx->runtime_spad, epoch, stake_weights_msg );
329+
ulong stake_weights_sz = generate_stake_weight_msg( slot_ctx, ctx->runtime_spad, epoch, next_epoch_stakes, stake_weights_msg );
330330
ulong stake_weights_sig = 4UL;
331331
fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) );
332332
ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark );

0 commit comments

Comments
 (0)