Skip to content

Commit 8d66020

Browse files
committed
Add vinyl support to replay tile
Also add housekeep callback to vinyl tile
1 parent a73f5ae commit 8d66020

File tree

13 files changed

+435
-27
lines changed

13 files changed

+435
-27
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../../shared/fd_config.h" /* config_t */
2121
#include "../../../disco/tiles.h"
2222
#include "../../../disco/topo/fd_topob.h"
23+
#include "../../../disco/topo/fd_topob_vinyl.h"
2324
#include "../../../util/pod/fd_pod_format.h"
2425
#include "../../../discof/replay/fd_replay_tile.h"
2526
#include "../../../discof/restore/utils/fd_ssctrl.h"
@@ -50,7 +51,7 @@ backtest_topo( config_t * config ) {
5051
ulong lta_tile_cnt = config->firedancer.layout.snapla_tile_count;
5152

5253
int disable_snap_loader = !config->gossip.entrypoints_cnt;
53-
int snap_vinyl = !!config->firedancer.vinyl.enabled;
54+
int vinyl_enabled = !!config->firedancer.vinyl.enabled;
5455
int solcap_enabled = strlen( config->capture.solcap_capture )>0;
5556
int snapshot_lthash_disabled = config->development.snapshots.disable_lthash_verification;
5657

@@ -91,7 +92,7 @@ backtest_topo( config_t * config ) {
9192
config->firedancer.runtime.program_cache.heap_size_mib<<20 );
9293
fd_topob_tile_uses( topo, replay_tile, progcache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
9394

94-
if( snap_vinyl ) {
95+
if( vinyl_enabled ) {
9596
setup_topo_vinyl_meta( topo, &config->firedancer );
9697
}
9798

@@ -105,7 +106,6 @@ backtest_topo( config_t * config ) {
105106
/**********************************************************************/
106107
/* Add the snapshot tiles to topo */
107108
/**********************************************************************/
108-
int vinyl_enabled = config->firedancer.vinyl.enabled;
109109
fd_topo_tile_t * snapin_tile = NULL;
110110
fd_topo_tile_t * snapwr_tile = NULL;
111111
if( FD_UNLIKELY( !disable_snap_loader ) ) {
@@ -352,7 +352,7 @@ backtest_topo( config_t * config ) {
352352
fd_topob_tile_uses( topo, replay_tile, txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
353353
if( FD_LIKELY( !disable_snap_loader ) ) {
354354
fd_topob_tile_uses( topo, snapin_tile, txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
355-
if( snap_vinyl ) {
355+
if( vinyl_enabled ) {
356356
ulong vinyl_map_obj_id = fd_pod_query_ulong( topo->props, "vinyl.meta_map", ULONG_MAX ); FD_TEST( vinyl_map_obj_id !=ULONG_MAX );
357357
ulong vinyl_pool_obj_id = fd_pod_query_ulong( topo->props, "vinyl.meta_pool", ULONG_MAX ); FD_TEST( vinyl_pool_obj_id!=ULONG_MAX );
358358
fd_topo_obj_t * vinyl_map_obj = &topo->objs[ vinyl_map_obj_id ];
@@ -376,6 +376,10 @@ backtest_topo( config_t * config ) {
376376
fd_topob_tile_uses( topo, snapin_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
377377
}
378378

379+
if( vinyl_enabled ) {
380+
fd_topob_vinyl_rq( topo, "replay", 0UL, "vinyl_replay", "replay", 1UL, 1UL, 1UL );
381+
}
382+
379383
for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
380384
fd_topo_tile_t * tile = &topo->tiles[ i ];
381385
fd_topo_configure_tile( tile, config );

src/app/firedancer-dev/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ extern fd_topo_obj_callbacks_t fd_obj_cb_funk;
2727
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta;
2828
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta_ele;
2929
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_data;
30+
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_req_pool;
31+
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_rq;
32+
extern fd_topo_obj_callbacks_t fd_obj_cb_vinyl_cq;
3033

3134
fd_topo_obj_callbacks_t * CALLBACKS[] = {
3235
&fd_obj_cb_mcache,
@@ -47,6 +50,9 @@ fd_topo_obj_callbacks_t * CALLBACKS[] = {
4750
&fd_obj_cb_vinyl_meta,
4851
&fd_obj_cb_vinyl_meta_ele,
4952
&fd_obj_cb_vinyl_data,
53+
&fd_obj_cb_vinyl_req_pool,
54+
&fd_obj_cb_vinyl_rq,
55+
&fd_obj_cb_vinyl_cq,
5056
NULL,
5157
};
5258

src/app/firedancer/callbacks_vinyl.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../../vinyl/fd_vinyl.h"
22
#include "../../disco/topo/fd_topo.h"
3+
#include "../../flamenco/accdb/fd_vinyl_req_pool.h"
34
#include "../../util/pod/fd_pod_format.h"
45

56
#define VAL(name) (__extension__({ \
@@ -111,3 +112,87 @@ fd_topo_obj_callbacks_t fd_obj_cb_vinyl_data = {
111112
.align = vinyl_data_align,
112113
.new = vinyl_data_new,
113114
};
115+
116+
/* vinyl_req_pool: request allocator */
117+
118+
static ulong
119+
vinyl_req_pool_align( fd_topo_t const * topo,
120+
fd_topo_obj_t const * obj ) {
121+
(void)topo; (void)obj;
122+
return fd_vinyl_req_pool_align();
123+
}
124+
125+
static ulong
126+
vinyl_req_pool_footprint( fd_topo_t const * topo,
127+
fd_topo_obj_t const * obj ) {
128+
return fd_vinyl_req_pool_footprint( VAL("batch_max"), VAL("batch_key_max") );
129+
}
130+
131+
static void
132+
vinyl_req_pool_new( fd_topo_t const * topo,
133+
fd_topo_obj_t const * obj ) {
134+
FD_TEST( fd_vinyl_req_pool_new( fd_topo_obj_laddr( topo, obj->id ), VAL("batch_max"), VAL("batch_key_max") ) );
135+
}
136+
137+
fd_topo_obj_callbacks_t fd_obj_cb_vinyl_req_pool = {
138+
.name = "vinyl_req_pool",
139+
.footprint = vinyl_req_pool_footprint,
140+
.align = vinyl_req_pool_align,
141+
.new = vinyl_req_pool_new,
142+
};
143+
144+
/* vinyl_rq: request queue */
145+
146+
static ulong
147+
vinyl_rq_align( fd_topo_t const * topo,
148+
fd_topo_obj_t const * obj ) {
149+
(void)topo; (void)obj;
150+
return fd_vinyl_rq_align();
151+
}
152+
153+
static ulong
154+
vinyl_rq_footprint( fd_topo_t const * topo,
155+
fd_topo_obj_t const * obj ) {
156+
return fd_vinyl_rq_footprint( VAL("req_cnt") );
157+
}
158+
159+
static void
160+
vinyl_rq_new( fd_topo_t const * topo,
161+
fd_topo_obj_t const * obj ) {
162+
FD_TEST( fd_vinyl_rq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("req_cnt") ) );
163+
}
164+
165+
fd_topo_obj_callbacks_t fd_obj_cb_vinyl_rq = {
166+
.name = "vinyl_rq",
167+
.footprint = vinyl_rq_footprint,
168+
.align = vinyl_rq_align,
169+
.new = vinyl_rq_new,
170+
};
171+
172+
/* vinyl_cq: completion queue */
173+
174+
static ulong
175+
vinyl_cq_align( fd_topo_t const * topo,
176+
fd_topo_obj_t const * obj ) {
177+
(void)topo; (void)obj;
178+
return fd_vinyl_cq_align();
179+
}
180+
181+
static ulong
182+
vinyl_cq_footprint( fd_topo_t const * topo,
183+
fd_topo_obj_t const * obj ) {
184+
return fd_vinyl_cq_footprint( VAL("comp_cnt") );
185+
}
186+
187+
static void
188+
vinyl_cq_new( fd_topo_t const * topo,
189+
fd_topo_obj_t const * obj ) {
190+
FD_TEST( fd_vinyl_cq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("comp_cnt") ) );
191+
}
192+
193+
fd_topo_obj_callbacks_t fd_obj_cb_vinyl_cq = {
194+
.name = "vinyl_cq",
195+
.footprint = vinyl_cq_footprint,
196+
.align = vinyl_cq_align,
197+
.new = vinyl_cq_new,
198+
};

src/app/firedancer/topology.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,12 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
12411241
tile->replay.funk_obj_id = fd_pod_query_ulong( config->topo.props, "funk", ULONG_MAX ); FD_TEST( tile->replay.funk_obj_id !=ULONG_MAX );
12421242
tile->replay.progcache_obj_id = fd_pod_query_ulong( config->topo.props, "progcache", ULONG_MAX ); FD_TEST( tile->replay.progcache_obj_id!=ULONG_MAX );
12431243

1244+
if( config->firedancer.vinyl.enabled ) {
1245+
tile->replay.vinyl_data_wksp_id = fd_pod_query_ulong( config->topo.props, "vinyl.data", ULONG_MAX ); FD_TEST( tile->replay.vinyl_data_wksp_id!=ULONG_MAX );
1246+
} else {
1247+
tile->replay.vinyl_data_wksp_id = ULONG_MAX;
1248+
}
1249+
12441250
tile->replay.max_live_slots = config->firedancer.runtime.max_live_slots;
12451251

12461252
tile->replay.expected_shred_version = config->consensus.expected_shred_version;

src/disco/topo/fd_topo.h

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ struct fd_topo_tile {
366366
ulong max_vote_accounts;
367367

368368
ulong funk_obj_id;
369+
ulong vinyl_data_wksp_id;
370+
369371
ulong txncache_obj_id;
370372
ulong progcache_obj_id;
371373

@@ -621,6 +623,10 @@ struct fd_topo_tile {
621623

622624
int io_type; /* FD_VINYL_IO_TYPE_* */
623625
uint uring_depth;
626+
627+
# define FD_TOPO_VINYL_LINK_MAX 16UL
628+
ulong rq_cnt;
629+
ulong rq_obj_id[ FD_TOPO_VINYL_LINK_MAX ];
624630
} vinyl;
625631
};
626632
};
@@ -629,9 +635,13 @@ typedef struct fd_topo_tile fd_topo_tile_t;
629635

630636
typedef struct {
631637
ulong id;
632-
char name[ 13UL ];
638+
char name[ 13UL ]; /* object type */
633639
ulong wksp_id;
634640

641+
/* Optional label for object */
642+
char label[ 13UL ]; /* object label */
643+
ulong label_idx; /* index of object for this label (ULONG_MAX if not labelled) */
644+
635645
ulong offset;
636646
ulong footprint;
637647
} fd_topo_obj_t;
@@ -885,6 +895,49 @@ fd_topo_tile_producer_cnt( fd_topo_t const * topo,
885895
return in_cnt;
886896
}
887897

898+
FD_FN_PURE FD_FN_UNUSED static ulong
899+
fd_topo_obj_cnt( fd_topo_t const * topo,
900+
char const * obj_type,
901+
char const * label ) {
902+
ulong cnt = 0UL;
903+
for( ulong i=0UL; i<topo->obj_cnt; i++ ) {
904+
fd_topo_obj_t const * obj = &topo->objs[ i ];
905+
if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
906+
if( label &&
907+
strncmp( obj->label, label, sizeof(obj->label) ) ) continue;
908+
cnt++;
909+
}
910+
return cnt;
911+
}
912+
913+
FD_FN_PURE FD_FN_UNUSED static fd_topo_obj_t const *
914+
fd_topo_find_obj( fd_topo_t const * topo,
915+
char const * obj_type,
916+
char const * label,
917+
ulong label_idx ) {
918+
for( ulong i=0UL; i<topo->obj_cnt; i++ ) {
919+
fd_topo_obj_t const * obj = &topo->objs[ i ];
920+
if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
921+
if( label &&
922+
strncmp( obj->label, label, sizeof(obj->label) ) ) continue;
923+
if( label_idx != ULONG_MAX && obj->label_idx != label_idx ) continue;
924+
return obj;
925+
}
926+
return NULL;
927+
}
928+
929+
FD_FN_PURE FD_FN_UNUSED static fd_topo_obj_t const *
930+
fd_topo_find_tile_obj( fd_topo_t const * topo,
931+
fd_topo_tile_t const * tile,
932+
char const * obj_type ) {
933+
for( ulong i=0UL; i<(tile->uses_obj_cnt); i++ ) {
934+
fd_topo_obj_t const * obj = &topo->objs[ tile->uses_obj_id[ i ] ];
935+
if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
936+
return obj;
937+
}
938+
return NULL;
939+
}
940+
888941
/* Join (map into the process) all shared memory (huge/gigantic pages)
889942
needed by the tile, in the given topology. All memory associated
890943
with the tile (aka. used by links that the tile either produces to or

src/disco/topo/fd_topob.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,32 @@ fd_topob_obj( fd_topo_t * topo,
5757
if( FD_UNLIKELY( wksp_id==ULONG_MAX ) ) FD_LOG_ERR(( "workspace not found: %s", wksp_name ));
5858

5959
fd_topo_obj_t * obj = &topo->objs[ topo->obj_cnt ];
60+
memset( obj, 0, sizeof(fd_topo_obj_t) );
6061
strncpy( obj->name, obj_name, sizeof(obj->name) );
61-
obj->id = topo->obj_cnt;
62-
obj->wksp_id = wksp_id;
62+
obj->id = topo->obj_cnt;
63+
obj->wksp_id = wksp_id;
64+
obj->label_idx = ULONG_MAX;
6365
topo->obj_cnt++;
6466

6567
return obj;
6668
}
6769

70+
fd_topo_obj_t *
71+
fd_topob_obj_named( fd_topo_t * topo,
72+
char const * obj_type,
73+
char const * wksp_name,
74+
char const * label ) {
75+
if( FD_UNLIKELY( !label ) ) FD_LOG_ERR(( "NULL args" ));
76+
if( FD_UNLIKELY( strlen( label )>=sizeof(topo->objs[ topo->obj_cnt ].label ) ) ) FD_LOG_ERR(( "obj label too long: %s", label ));
77+
fd_topo_obj_t * obj = fd_topob_obj( topo, obj_type, wksp_name );
78+
if( FD_UNLIKELY( !obj ) ) return NULL;
79+
80+
fd_cstr_ncpy( obj->label, label, sizeof(obj->label) );
81+
obj->label_idx = fd_topo_obj_cnt( topo, obj_type, label );
82+
83+
return obj;
84+
}
85+
6886
fd_topo_link_t *
6987
fd_topob_link( fd_topo_t * topo,
7088
char const * link_name,
@@ -106,10 +124,10 @@ fd_topob_link( fd_topo_t * topo,
106124
}
107125

108126
void
109-
fd_topob_tile_uses( fd_topo_t * topo,
110-
fd_topo_tile_t * tile,
111-
fd_topo_obj_t * obj,
112-
int mode ) {
127+
fd_topob_tile_uses( fd_topo_t * topo,
128+
fd_topo_tile_t * tile,
129+
fd_topo_obj_t const * obj,
130+
int mode ) {
113131
(void)topo;
114132

115133
if( FD_UNLIKELY( tile->uses_obj_cnt>=FD_TOPO_MAX_TILE_OBJS ) ) FD_LOG_ERR(( "tile `%s` uses too many objects", tile->name ));

src/disco/topo/fd_topob.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fd_topo_wksp_t *
4040
fd_topob_wksp( fd_topo_t * topo,
4141
char const * name );
4242

43-
/* Add an object with the given name to the toplogy. An object is
43+
/* Add an object with the given type to the toplogy. An object is
4444
something that takes up space in memory, in a workspace.
4545
4646
The workspace must exist and have been added to the topology.
@@ -50,9 +50,17 @@ fd_topob_wksp( fd_topo_t * topo,
5050

5151
fd_topo_obj_t *
5252
fd_topob_obj( fd_topo_t * topo,
53-
char const * obj_name,
53+
char const * obj_type,
5454
char const * wksp_name );
5555

56+
/* Same as fd_topo_obj, but labels the object. */
57+
58+
fd_topo_obj_t *
59+
fd_topob_obj_named( fd_topo_t * topo,
60+
char const * obj_type,
61+
char const * wksp_name,
62+
char const * label );
63+
5664
/* Add a relationship saying that a certain tile uses a given object.
5765
This has the effect that when memory mapping required workspaces
5866
for a tile, it will map the workspace required for this object in
@@ -62,10 +70,10 @@ fd_topob_obj( fd_topo_t * topo,
6270
FD_SHMEM_JOIN_MODE_READ_WRITE. */
6371

6472
void
65-
fd_topob_tile_uses( fd_topo_t * topo,
66-
fd_topo_tile_t * tile,
67-
fd_topo_obj_t * obj,
68-
int mode );
73+
fd_topob_tile_uses( fd_topo_t * topo,
74+
fd_topo_tile_t * tile,
75+
fd_topo_obj_t const * obj,
76+
int mode );
6977

7078
/* Add a link to the toplogy. The link will not have any producer or
7179
consumer(s) by default, and those need to be added after. The link

0 commit comments

Comments
 (0)