Skip to content

Commit 1898a05

Browse files
backtest: aggressive rocksdb tower publishing
1 parent 8471849 commit 1898a05

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

src/discof/backtest/fd_backtest_tile.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ typedef struct {
102102
fd_store_t * store;
103103
fd_tower_t * tower;
104104
fd_shred_t const * curr;
105+
106+
/* is_ready is used to determine if the backtest tile should send
107+
more fec sets to the replay tile. is_ready==1 if more fec sets
108+
should be sent; it gets set to 0 while waiting for an end of slot
109+
notification from the replay tile. When a slot notification is
110+
received, is_ready is set to 1 again. */
111+
int is_ready;
105112
} ctx_t;
106113

107114
FD_FN_CONST static inline ulong
@@ -181,9 +188,18 @@ notify_tower_root( ctx_t * ctx,
181188
ulong tsorig,
182189
ulong tspub ) {
183190
ulong replayed_slot = ctx->replay_notification.slot_exec.slot;
184-
ulong root = fd_tower_vote( ctx->tower, replayed_slot );
185-
if( FD_LIKELY( root != FD_SLOT_NULL ) ) {
186-
fd_stem_publish( stem, ctx->tower_replay_out_idx, root, 0UL, 0UL, 0UL, tsorig, tspub );
191+
if( ctx->ingest_mode == FD_BACKTEST_ROCKSDB_INGEST ) {
192+
/* We want to publish the previous last_replayed_slot, when we have
193+
finished replaying the current slot. Then we can update the
194+
last_replayed_slot to the newly executed slot. */
195+
fd_stem_publish( stem, ctx->tower_replay_out_idx, ctx->replay_notification.slot_exec.slot, 0UL, 0UL, 0UL, tsorig, tspub );
196+
ctx->is_ready = 1;
197+
198+
} else if( ctx->ingest_mode == FD_BACKTEST_SHREDCAP_INGEST ) {
199+
ulong root = fd_tower_vote( ctx->tower, replayed_slot );
200+
if( FD_LIKELY( root != FD_SLOT_NULL ) ) {
201+
fd_stem_publish( stem, ctx->tower_replay_out_idx, root, 0UL, 0UL, 0UL, tsorig, tspub );
202+
}
187203
}
188204
}
189205

@@ -307,6 +323,10 @@ unprivileged_init( fd_topo_t * topo,
307323
ctx->slot_cnt = 0UL;
308324

309325
ctx->curr = NULL;
326+
327+
ctx->is_ready = 1;
328+
329+
FD_LOG_NOTICE(( "Finished unprivileged init" ));
310330
}
311331

312332
fd_hash_t
@@ -340,6 +360,14 @@ after_credit_rocksdb( ctx_t * ctx,
340360
ctx->rocksdb_iter = rocksdb_create_iterator_cf(ctx->rocksdb.db, ctx->rocksdb.ro, ctx->rocksdb.cf_handles[FD_ROCKSDB_CFIDX_DATA_SHRED]);
341361
}
342362

363+
/* If the slot we just sent to the replay tile has not finished
364+
replaying, then we will block until it's done replaying and a
365+
notification is received from the replay tile. */
366+
367+
if( ctx->is_ready==0 ) {
368+
return;
369+
}
370+
343371
ulong sz;
344372
fd_shred_t const * prev = NULL;
345373
fd_shred_t const * curr = ctx->curr ? ctx->curr : rocksdb_get_shred( ctx, &sz );
@@ -380,6 +408,11 @@ after_credit_rocksdb( ctx_t * ctx,
380408
ctx->replay_out_chunk = fd_dcache_compact_next( ctx->replay_out_chunk, sizeof(fd_fec_out_t), ctx->replay_out_chunk0, ctx->replay_out_wmark );
381409
ctx->curr = curr;
382410
*charge_busy = 1;
411+
412+
if( out.slot_complete ) {
413+
ctx->is_ready = 0;
414+
}
415+
383416
return; /* yield otherwise it will overrun */
384417
}
385418

src/discof/replay/fd_replay_tile.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,11 +1023,8 @@ after_frag( fd_replay_tile_ctx_t * ctx,
10231023
if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_TOWER ) ) {
10241024
ulong root = sig;
10251025

1026-
if( FD_LIKELY( root <= fd_fseq_query( ctx->published_wmark ) ) ) return;
1027-
1028-
ulong const slot = fd_bank_slot_get( ctx->slot_ctx->bank );
1029-
if( FD_UNLIKELY( slot==root ) ) {
1030-
FD_LOG_CRIT(( "invariant violation: root %lu is the same as the current slot %lu", root, slot ));
1026+
if( FD_LIKELY( root <= fd_fseq_query( ctx->published_wmark ) ) ) {
1027+
return;
10311028
}
10321029

10331030
ctx->root = root;
@@ -1373,9 +1370,6 @@ handle_new_slot( fd_replay_tile_ctx_t * ctx,
13731370
}
13741371

13751372
fd_funk_txn_t * parent_txn = fd_funk_txn_query( &parent_xid, txn_map );
1376-
if( FD_UNLIKELY( !parent_txn && parent_slot!=ctx->snapshot_slot ) ) {
1377-
FD_LOG_CRIT(( "parent_txn is NULL for slot %lu", parent_slot ));
1378-
}
13791373

13801374
fd_funk_txn_t * funk_txn = fd_funk_txn_prepare( ctx->funk, parent_txn, &xid, 1 );
13811375
if( FD_UNLIKELY( !funk_txn ) ) {

src/flamenco/runtime/fd_bank.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fd_banks_clone_from_parent( fd_banks_t * banks,
517517
fd_bank_t * parent_bank = fd_banks_map_ele_query( bank_map, &parent_slot, NULL, bank_pool );
518518

519519
if( FD_UNLIKELY( !parent_bank ) ) {
520-
FD_LOG_WARNING(( "Failed to get bank" ));
520+
FD_LOG_WARNING(( "Failed to get bank for parent slot %lu", parent_slot ));
521521
fd_rwlock_unwrite( &banks->rwlock );
522522
return NULL;
523523
}

src/flamenco/runtime/tests/run_ledger_backtest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ echo "
176176
[runtime]
177177
heap_size_gib = 50
178178
[runtime.limits]
179-
max_total_banks = 46
180-
max_fork_width = 32
179+
max_total_banks = 4
180+
max_fork_width = 4
181181
[development]
182182
sandbox = false
183183
no_agave = true

0 commit comments

Comments
 (0)