Skip to content

Commit 569b93a

Browse files
riptlripatel-fd
authored andcommitted
Use fd_stem_publish for net out
1 parent 1e4ac81 commit 569b93a

File tree

5 files changed

+54
-89
lines changed

5 files changed

+54
-89
lines changed

src/disco/quic/fd_quic_tile.c

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <linux/unistd.h>
1212
#include <sys/random.h>
1313

14+
#define OUT_IDX_VERIFY 0
15+
#define OUT_IDX_NET 1
16+
1417
/* fd_quic_tile provides a TPU server tile.
1518
1619
This tile handles incoming transactions that clients request to be
@@ -89,14 +92,6 @@ legacy_stream_notify( fd_quic_ctx_t * ctx,
8992
}
9093
}
9194

92-
/* Because of the separate mcache for publishing network fragments
93-
back to networking tiles, which is not managed by fd_stem, we
94-
need to periodically update the sync. */
95-
static void
96-
during_housekeeping( fd_quic_ctx_t * ctx ) {
97-
fd_mcache_seq_update( ctx->net_out_sync, ctx->net_out_seq );
98-
}
99-
10095
/* This tile always publishes messages downstream, even if there are
10196
no credits available. It ignores the flow control of the downstream
10297
verify tile. This is OK as the verify tile is written to expect
@@ -409,19 +404,11 @@ quic_tx_aio_send( void * _ctx,
409404
just indicate where they came from so they don't bounce back */
410405
ulong sig = fd_disco_netmux_sig( ip_dst, 0U, ip_dst, DST_PROTO_OUTGOING, FD_NETMUX_SIG_MIN_HDR_SZ );
411406

412-
long tspub = fd_tickcount();
413-
fd_mcache_publish( ctx->net_out_mcache,
414-
ctx->net_out_depth,
415-
ctx->net_out_seq,
416-
sig,
417-
ctx->net_out_chunk,
418-
sz_l2,
419-
fd_frag_meta_ctl( 0UL, 1, 1, 0 ),
420-
0,
421-
fd_frag_meta_ts_comp( tspub ) );
422-
423-
ctx->net_out_seq = fd_seq_inc( ctx->net_out_seq, 1UL );
424-
ctx->net_out_chunk = fd_dcache_compact_next( ctx->net_out_chunk, FD_NET_MTU, ctx->net_out_chunk0, ctx->net_out_wmark );
407+
ulong chunk = ctx->net_out_chunk;
408+
ulong ctl = fd_frag_meta_ctl( 0UL, 1, 1, 0 );
409+
fd_stem_publish( ctx->stem, OUT_IDX_NET, sig, chunk, sz_l2, ctl, 0L, 0L );
410+
411+
ctx->net_out_chunk = fd_dcache_compact_next( chunk, FD_NET_MTU, ctx->net_out_chunk0, ctx->net_out_wmark );
425412
}
426413

427414
if( FD_LIKELY( opt_batch_idx ) ) {
@@ -475,8 +462,8 @@ unprivileged_init( fd_topo_t * topo,
475462
}
476463

477464
if( FD_UNLIKELY( tile->out_cnt!=2UL ||
478-
strcmp( topo->links[ tile->out_link_id[ 0UL ] ].name, "quic_verify" ) ||
479-
strcmp( topo->links[ tile->out_link_id[ 1UL ] ].name, "quic_net" ) ) )
465+
strcmp( topo->links[ tile->out_link_id[ OUT_IDX_VERIFY ] ].name, "quic_verify" ) ||
466+
strcmp( topo->links[ tile->out_link_id[ OUT_IDX_NET ] ].name, "quic_net" ) ) )
480467
FD_LOG_ERR(( "quic tile has none or unexpected output links %lu %s %s",
481468
tile->out_cnt, topo->links[ tile->out_link_id[ 0 ] ].name, topo->links[ tile->out_link_id[ 1 ] ].name ));
482469

@@ -549,10 +536,6 @@ unprivileged_init( fd_topo_t * topo,
549536

550537
fd_topo_link_t * net_out = &topo->links[ tile->out_link_id[ 1 ] ];
551538

552-
ctx->net_out_mcache = net_out->mcache;
553-
ctx->net_out_sync = fd_mcache_seq_laddr( ctx->net_out_mcache );
554-
ctx->net_out_depth = fd_mcache_depth( ctx->net_out_mcache );
555-
ctx->net_out_seq = fd_mcache_seq_query( ctx->net_out_sync );
556539
ctx->net_out_mem = topo->workspaces[ topo->objs[ net_out->dcache_obj_id ].wksp_id ].wksp;
557540
ctx->net_out_chunk0 = fd_dcache_compact_chunk0( ctx->net_out_mem, net_out->dcache );
558541
ctx->net_out_wmark = fd_dcache_compact_wmark ( ctx->net_out_mem, net_out->dcache, net_out->mtu );
@@ -615,12 +598,11 @@ populate_allowed_fds( fd_topo_t const * topo,
615598
#define STEM_CALLBACK_CONTEXT_TYPE fd_quic_ctx_t
616599
#define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_quic_ctx_t)
617600

618-
#define STEM_CALLBACK_DURING_HOUSEKEEPING during_housekeeping
619-
#define STEM_CALLBACK_METRICS_WRITE metrics_write
620-
#define STEM_CALLBACK_BEFORE_CREDIT before_credit
621-
#define STEM_CALLBACK_BEFORE_FRAG before_frag
622-
#define STEM_CALLBACK_DURING_FRAG during_frag
623-
#define STEM_CALLBACK_AFTER_FRAG after_frag
601+
#define STEM_CALLBACK_METRICS_WRITE metrics_write
602+
#define STEM_CALLBACK_BEFORE_CREDIT before_credit
603+
#define STEM_CALLBACK_BEFORE_FRAG before_frag
604+
#define STEM_CALLBACK_DURING_FRAG during_frag
605+
#define STEM_CALLBACK_AFTER_FRAG after_frag
624606

625607
#include "../stem/fd_stem.c"
626608

src/disco/quic/fd_quic_tile.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ typedef struct {
3232

3333
fd_net_rx_bounds_t net_in_bounds[ FD_QUIC_TILE_IN_MAX ];
3434

35-
fd_frag_meta_t * net_out_mcache;
36-
ulong * net_out_sync;
37-
ulong net_out_depth;
38-
ulong net_out_seq;
39-
4035
fd_wksp_t * net_out_mem;
4136
ulong net_out_chunk0;
4237
ulong net_out_wmark;

src/disco/shred/fd_shred_tile.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ typedef struct {
182182
fd_shred_in_ctx_t in[ 32 ];
183183
int in_kind[ 32 ];
184184

185-
fd_frag_meta_t * net_out_mcache;
186-
ulong * net_out_sync;
187-
ulong net_out_depth;
188-
ulong net_out_seq;
189-
190185
fd_wksp_t * net_out_mem;
191186
ulong net_out_chunk0;
192187
ulong net_out_wmark;
@@ -620,6 +615,7 @@ during_frag( fd_shred_ctx_t * ctx,
620615

621616
static inline void
622617
send_shred( fd_shred_ctx_t * ctx,
618+
fd_stem_context_t * stem,
623619
fd_shred_t const * shred,
624620
fd_shred_dest_weighted_t const * dest,
625621
ulong tsorig ) {
@@ -673,9 +669,9 @@ send_shred( fd_shred_ctx_t * ctx,
673669
ulong pkt_sz = shred_sz + sizeof(fd_ip4_udp_hdrs_t);
674670
ulong tspub = fd_frag_meta_ts_comp( fd_tickcount() );
675671
ulong sig = fd_disco_netmux_sig( dest->ip4, dest->port, dest->ip4, DST_PROTO_OUTGOING, sizeof(fd_ip4_udp_hdrs_t) );
676-
fd_mcache_publish( ctx->net_out_mcache, ctx->net_out_depth, ctx->net_out_seq, sig, ctx->net_out_chunk, pkt_sz, 0UL, tsorig, tspub );
677-
ctx->net_out_seq = fd_seq_inc( ctx->net_out_seq, 1UL );
678-
ctx->net_out_chunk = fd_dcache_compact_next( ctx->net_out_chunk, pkt_sz, ctx->net_out_chunk0, ctx->net_out_wmark );
672+
ulong const chunk = ctx->net_out_chunk;
673+
fd_stem_publish( stem, NET_OUT_IDX, sig, chunk, pkt_sz, 0UL, tsorig, tspub );
674+
ctx->net_out_chunk = fd_dcache_compact_next( chunk, pkt_sz, ctx->net_out_chunk0, ctx->net_out_wmark );
679675
}
680676

681677
static void
@@ -832,8 +828,8 @@ after_frag( fd_shred_ctx_t * ctx,
832828
fd_shred_dest_idx_t * dests = fd_shred_dest_compute_children( sdest, &shred, 1UL, ctx->scratchpad_dests, 1UL, fanout, fanout, max_dest_cnt );
833829
if( FD_UNLIKELY( !dests ) ) break;
834830

835-
send_shred( ctx, *out_shred, ctx->adtl_dest, ctx->tsorig );
836-
for( ulong j=0UL; j<*max_dest_cnt; j++ ) send_shred( ctx, *out_shred, fd_shred_dest_idx_to_dest( sdest, dests[ j ]), ctx->tsorig );
831+
send_shred( ctx, stem, *out_shred, ctx->adtl_dest, ctx->tsorig );
832+
for( ulong j=0UL; j<*max_dest_cnt; j++ ) send_shred( ctx, stem, *out_shred, fd_shred_dest_idx_to_dest( sdest, dests[ j ]), ctx->tsorig );
837833
} while( 0 );
838834
}
839835

@@ -985,8 +981,8 @@ after_frag( fd_shred_ctx_t * ctx,
985981

986982
/* Send only the ones we didn't receive. */
987983
for( ulong i=0UL; i<k; i++ ) {
988-
send_shred( ctx, new_shreds[ i ], ctx->adtl_dest, ctx->tsorig );
989-
for( ulong j=0UL; j<*max_dest_cnt; j++ ) send_shred( ctx, new_shreds[ i ], fd_shred_dest_idx_to_dest( sdest, dests[ j*out_stride+i ]), ctx->tsorig );
984+
send_shred( ctx, stem, new_shreds[ i ], ctx->adtl_dest, ctx->tsorig );
985+
for( ulong j=0UL; j<*max_dest_cnt; j++ ) send_shred( ctx, stem, new_shreds[ i ], fd_shred_dest_idx_to_dest( sdest, dests[ j*out_stride+i ]), ctx->tsorig );
990986
}
991987
}
992988
}
@@ -1180,10 +1176,6 @@ unprivileged_init( fd_topo_t * topo,
11801176

11811177
fd_topo_link_t * net_out = &topo->links[ tile->out_link_id[ NET_OUT_IDX ] ];
11821178

1183-
ctx->net_out_mcache = net_out->mcache;
1184-
ctx->net_out_sync = fd_mcache_seq_laddr( ctx->net_out_mcache );
1185-
ctx->net_out_depth = fd_mcache_depth( ctx->net_out_mcache );
1186-
ctx->net_out_seq = fd_mcache_seq_query( ctx->net_out_sync );
11871179
ctx->net_out_chunk0 = fd_dcache_compact_chunk0( fd_wksp_containing( net_out->dcache ), net_out->dcache );
11881180
ctx->net_out_mem = topo->workspaces[ topo->objs[ net_out->dcache_obj_id ].wksp_id ].wksp;
11891181
ctx->net_out_wmark = fd_dcache_compact_wmark ( ctx->net_out_mem, net_out->dcache, net_out->mtu );

src/discof/backtest/fd_backtest_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../../disco/tiles.h"
1+
#include "../../disco/topo/fd_topo.h"
22
#include "../../disco/fd_disco.h"
33
#include "../../disco/stem/fd_stem.h"
44
#include "../../choreo/tower/fd_tower.h"

0 commit comments

Comments
 (0)