Skip to content

Commit 8608f30

Browse files
committed
solcap: version ULONGMAX
1 parent 06fab31 commit 8608f30

32 files changed

+1213
-3720
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ backtest_topo( config_t * config ) {
8787
#define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
8888
FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
8989
90+
/**********************************************************************/
91+
/* Add the capture tile to topo */
92+
/**********************************************************************/
93+
if (solcap_enabled) {
94+
fd_topob_wksp( topo, "captur" );
95+
fd_topob_tile( topo, "captur", "captur", "metric_in", cpu_idx++, 0, 0 );
96+
}
97+
9098
/**********************************************************************/
9199
/* Add the snapshot tiles to topo */
92100
/**********************************************************************/
@@ -228,7 +236,7 @@ backtest_topo( config_t * config ) {
228236
link for this without introducing a race. This will get removed with solcap V2. */
229237
if( FD_UNLIKELY( solcap_enabled ) ) {
230238
/* TODO: remove this with solcap V2 */
231-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
239+
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, 4096UL, 1UL );
232240
} else {
233241
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
234242
}
@@ -240,6 +248,15 @@ backtest_topo( config_t * config ) {
240248
/* Setup the shared objs used by replay and exec tiles */
241249
/**********************************************************************/
242250

251+
if ( FD_UNLIKELY( solcap_enabled) ) {
252+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
253+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
254+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
255+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
256+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
257+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
258+
}
259+
243260
fd_topob_wksp( topo, "store" );
244261
fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
245262
fd_topob_tile_uses( topo, backt_tile, store_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );

src/app/firedancer-dev/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_feeder;
101101
extern fd_topo_run_tile_t fd_tile_archiver_writer;
102102
extern fd_topo_run_tile_t fd_tile_archiver_playback;
103103
extern fd_topo_run_tile_t fd_tile_shredcap;
104+
extern fd_topo_run_tile_t fd_tile_captur;
104105

105106
extern fd_topo_run_tile_t fd_tile_snaprd;
106107
extern fd_topo_run_tile_t fd_tile_snapdc;
@@ -152,6 +153,7 @@ fd_topo_run_tile_t * TILES[] = {
152153
&fd_tile_snapin,
153154
&fd_tile_genesi,
154155
&fd_tile_ipecho,
156+
&fd_tile_captur,
155157
NULL,
156158
};
157159

src/app/firedancer/callbacks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "../../flamenco/runtime/fd_bank.h"
66
#include "../../flamenco/runtime/fd_runtime.h"
77
#include "../../flamenco/runtime/fd_txncache_shmem.h"
8+
#include "../../flamenco/capture/fd_capture_tile.h"
89

910
#define VAL(name) (__extension__({ \
1011
ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \

src/app/firedancer/topology.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ setup_topo_txncache( fd_topo_t * topo,
123123
return obj;
124124
}
125125

126+
fd_topo_obj_t *
127+
setup_topo_capctx_buf( fd_topo_t * topo, char const * wksp_name, char const * path ) {
128+
fd_topo_obj_t * obj = fd_topob_obj( topo, "capctx_buf", wksp_name );
129+
FD_TEST( fd_pod_insertf_cstr( topo->props, path, "obj.%lu.path", obj->id ) );
130+
return obj;
131+
}
132+
126133
static int
127134
resolve_address( char const * address,
128135
uint * ip_addr ) {
@@ -903,6 +910,7 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
903910

904911
tile->replay.txncache_obj_id = fd_pod_query_ulong( config->topo.props, "txncache", ULONG_MAX );
905912
tile->replay.funk_obj_id = fd_pod_query_ulong( config->topo.props, "funk", ULONG_MAX );
913+
tile->replay.capctx_obj_id = fd_pod_query_ulong( config->topo.props, "capctx", ULONG_MAX );
906914

907915
strncpy( tile->replay.cluster_version, config->tiles.replay.cluster_version, sizeof(tile->replay.cluster_version) );
908916

@@ -927,6 +935,7 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
927935

928936
tile->exec.funk_obj_id = fd_pod_query_ulong( config->topo.props, "funk", ULONG_MAX );
929937
tile->exec.txncache_obj_id = fd_pod_query_ulong( config->topo.props, "txncache", ULONG_MAX );
938+
tile->exec.capctx_obj_id = fd_pod_query_ulong( config->topo.props, "capctx", ULONG_MAX );
930939

931940
tile->exec.max_live_slots = config->firedancer.runtime.max_live_slots;
932941

@@ -1119,6 +1128,10 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
11191128
tile->shredcap.enable_publish_stake_weights = 0; /* this is not part of the config */
11201129
strncpy( tile->shredcap.manifest_path, "", PATH_MAX ); /* this is not part of the config */
11211130

1131+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1132+
1133+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1134+
11221135
} else {
11231136
FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));
11241137
}

src/app/firedancer/topology.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ setup_topo_txncache( fd_topo_t * topo,
4747
ulong max_live_slots,
4848
ulong max_txn_per_slot );
4949

50+
fd_topo_obj_t *
51+
setup_topo_capctx_buf( fd_topo_t * topo, char const * wksp_name, char const * path );
52+
5053
void
5154
fd_topo_configure_tile( fd_topo_tile_t * tile,
5255
fd_config_t * config );

src/app/shared/fd_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ struct fd_configf {
155155
struct {
156156
ulong max_completed_shred_sets;
157157
} store;
158+
159+
struct {
160+
char path[ PATH_MAX ];
161+
} capctx;
158162
};
159163

160164
typedef struct fd_configf fd_configf_t;

src/disco/stem/fd_stem.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
or monitoring tools. The ctx is a user-provided context object from
3838
when the stem tile was initialized.
3939
40+
CUSTOM_INPUT_SELECTION
41+
Is called to determine if the stem should shuffle the input
42+
selection. The ctx is a user-provided context object from when the
43+
stem tile was initialized. The stem should return 1 if the input
44+
selection should be shuffled, 0 otherwise. Used alongside
45+
STEM_CUSTOM_INPUT_ADVANCE_FLAG to determine if the input selection
46+
should be advanced.
47+
4048
BEFORE_CREDIT
4149
Is called every iteration of the stem run loop, whether there is a
4250
new frag ready to receive or not. This callback is also still
@@ -484,14 +492,19 @@ STEM_(run1)( ulong in_cnt,
484492
/* We also do the same with the ins to prevent there being a
485493
correlated order frag origins from different inputs
486494
downstream at extreme fan in and extreme in load. */
487-
488-
if( FD_LIKELY( in_cnt>1UL ) ) {
495+
#ifdef STEM_CUSTOM_INPUT_SELECTION
496+
int shuffle_flag = STEM_CUSTOM_INPUT_ADVANCE_FLAG(ctx);
497+
#else
498+
int shuffle_flag = 1;
499+
#endif
500+
if( FD_LIKELY( in_cnt>1UL && shuffle_flag ) ) {
489501
swap_idx = (ulong)fd_rng_uint_roll( rng, (uint)in_cnt );
490502
fd_stem_tile_in_t in_tmp;
491503
in_tmp = in[ swap_idx ];
492504
in[ swap_idx ] = in[ 0 ];
493505
in[ 0 ] = in_tmp;
494506
}
507+
495508
}
496509

497510
/* Reload housekeeping timer */
@@ -579,10 +592,12 @@ STEM_(run1)( ulong in_cnt,
579592
}
580593
#endif
581594

582-
fd_stem_tile_in_t * this_in = &in[ in_seq ];
595+
fd_stem_tile_in_t * this_in = &in[ in_seq ];
596+
#ifdef STEM_CUSTOM_INPUT_SELECTION
597+
#else
583598
in_seq++;
584599
if( in_seq>=in_cnt ) in_seq = 0UL; /* cmov */
585-
600+
#endif
586601
/* Check if this in has any new fragments to mux */
587602

588603
ulong this_in_seq = this_in->seq;
@@ -714,6 +729,15 @@ STEM_(run1)( ulong in_cnt,
714729
this_in->accum[ FD_METRICS_COUNTER_LINK_CONSUMED_COUNT_OFF ]++;
715730
this_in->accum[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ] += (uint)sz;
716731

732+
/* Custom input selection: advance to next input based on flag */
733+
#ifdef STEM_CUSTOM_INPUT_SELECTION
734+
int should_advance = STEM_CUSTOM_INPUT_ADVANCE_FLAG(ctx);
735+
if( FD_LIKELY( should_advance ) ) {
736+
in_seq++;
737+
if( in_seq>=in_cnt ) in_seq = 0UL; /* cmov */
738+
}
739+
#endif
740+
717741
metric_regime_ticks[1] += housekeeping_ticks;
718742
metric_regime_ticks[4] += prefrag_ticks;
719743
long next = fd_tickcount();
@@ -815,3 +839,5 @@ STEM_(run)( fd_topo_t * topo,
815839
#undef STEM_CALLBACK_RETURNABLE_FRAG
816840
#undef STEM_CALLBACK_AFTER_FRAG
817841
#undef STEM_CALLBACK_AFTER_POLL_OVERRUN
842+
#undef STEM_CUSTOM_INPUT_SELECTION
843+
#undef STEM_CUSTOM_INPUT_ADVANCE_FLAG

src/disco/topo/fd_topo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ struct fd_topo_tile {
353353
int tx_metadata_storage;
354354
ulong funk_obj_id;
355355
ulong txncache_obj_id;
356+
ulong capctx_obj_id;
356357

357358
char shred_cap[ PATH_MAX ];
358359
char cluster_version[ 32 ];
@@ -381,6 +382,7 @@ struct fd_topo_tile {
381382
struct {
382383
ulong funk_obj_id;
383384
ulong txncache_obj_id;
385+
ulong capctx_obj_id;
384386

385387
ulong max_live_slots;
386388

@@ -560,6 +562,11 @@ struct fd_topo_tile {
560562

561563
char genesis_path[ PATH_MAX ];
562564
} genesi;
565+
566+
struct {
567+
ulong capture_ctx_obj_id;
568+
char solcap_capture[ PATH_MAX ];
569+
} capctx;
563570
};
564571
};
565572

src/discof/capture/Local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$(call add-objs,fd_capture_tile,fd_discof)

0 commit comments

Comments
 (0)