Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce XDP_STATISTICS rate in net tile #4062

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app/fdctl/fdctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ fdctl_obj_loose( fd_topo_t const * topo,
fd_topo_run_tile_t
fdctl_tile_run( fd_topo_tile_t * tile );

#define ACTIONS_CNT (11UL)
extern action_t ACTIONS[ ACTIONS_CNT ];
extern action_t ACTIONS[];

void fdctl_boot( int * pargc,
char *** pargv,
Expand Down
2 changes: 1 addition & 1 deletion src/app/fdctl/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help_cmd_fn( args_t * args,
--config parameter. */
FD_LOG_STDOUT(( " --config <PATH> Path to config TOML file\n\n" ));
FD_LOG_STDOUT(( "SUBCOMMANDS:\n" ));
for( ulong i=0; i<ACTIONS_CNT ; i++ ) {
for( ulong i=0; ACTIONS[ i ].name ; i++ ) {
FD_LOG_STDOUT(( " %9s %s\n", ACTIONS[ i ].name, ACTIONS[ i ].description ));
}
}
5 changes: 3 additions & 2 deletions src/app/fdctl/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <fcntl.h>
#include <sys/mman.h>

action_t ACTIONS[ ACTIONS_CNT ] = {
action_t ACTIONS[] = {
{ .name = "run", .args = NULL, .fn = run_cmd_fn, .perm = run_cmd_perm, .description = "Start up a Firedancer validator" },
{ .name = "run1", .args = run1_cmd_args, .fn = run1_cmd_fn, .perm = NULL, .description = "Start up a single Firedancer tile" },
{ .name = "run-agave", .args = NULL, .fn = run_agave_cmd_fn, .perm = NULL, .description = "Start up the Agave side of a Firedancer validator" },
Expand All @@ -18,6 +18,7 @@ action_t ACTIONS[ ACTIONS_CNT ] = {
{ .name = "spy", .args = NULL, .fn = spy_cmd_fn, .perm = NULL, .description = "Spy on and print out gossip traffic" },
{ .name = "help", .args = NULL, .fn = help_cmd_fn, .perm = NULL, .description = "Print this help message" },
{ .name = "version", .args = NULL, .fn = version_cmd_fn, .perm = NULL, .description = "Show the current software version" },
{0}
};

struct action_alias {
Expand Down Expand Up @@ -278,7 +279,7 @@ main1( int argc,
}

action_t * action = NULL;
for( ulong i=0; i<ACTIONS_CNT; i++ ) {
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( command, ACTIONS[ i ].name ) ) ) {
action = &ACTIONS[ i ];
break;
Expand Down
43 changes: 29 additions & 14 deletions src/app/fdctl/run/tiles/fd_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@

#define MAX_NET_INS (32UL)

#define FD_NETLINK_REFRESH_INTERVAL_NS (60e9) /* 60s */
#define FD_XDP_STATS_INTERVAL_NS (11e6) /* 11ms */

typedef struct {
fd_wksp_t * mem;
ulong chunk0;
Expand Down Expand Up @@ -102,8 +105,13 @@ typedef struct {
fd_net_out_ctx_t gossip_out[1];
fd_net_out_ctx_t repair_out[1];

/* Housekeeping timers (measured in fd_tickcount()) */
long netlink_refresh_interval_ticks;
long xdp_stats_interval_ticks;
long next_netlink_refresh;
long next_xdp_stats_refresh;

fd_ip_t * ip;
long ip_next_upd;

struct {
ulong tx_dropped_cnt;
Expand Down Expand Up @@ -321,17 +329,23 @@ poll_xdp_statistics( fd_net_ctx_t * ctx ) {

static void
during_housekeeping( fd_net_ctx_t * ctx ) {
long now = fd_log_wallclock();
if( FD_UNLIKELY( now > ctx->ip_next_upd ) ) {
ctx->ip_next_upd = now + (long)60e9;
long now = fd_tickcount();

if( now > ctx->next_xdp_stats_refresh ) {
ctx->next_xdp_stats_refresh = now + ctx->xdp_stats_interval_ticks;

/* Only net tile 0 polls the statistics, as they are retrieved for the
XDP socket which is shared across all net tiles.
(FIXME the above comment is wrong) */

if( FD_LIKELY( !ctx->round_robin_id ) ) poll_xdp_statistics( ctx );
}

if( now > ctx->next_netlink_refresh ) {
ctx->next_netlink_refresh = now + ctx->netlink_refresh_interval_ticks;
fd_ip_arp_fetch( ctx->ip );
fd_ip_route_fetch( ctx->ip );
}

/* Only net tile 0 polls the statistics, as they are retrieved for the
XDP socket which is shared across all net tiles. */

if( FD_LIKELY( !ctx->round_robin_id ) ) poll_xdp_statistics( ctx );
}

FD_FN_PURE static int
Expand Down Expand Up @@ -454,7 +468,6 @@ after_frag( fd_net_ctx_t * ctx,
rtn = fd_ip_route_ip_addr( dst_mac, &next_hop, &if_idx, ctx->ip, dst_ip );
}

long now;
switch( rtn ) {
case FD_IP_PROBE_RQD:
/* TODO possibly buffer some data while waiting for ARPs to complete */
Expand All @@ -463,8 +476,7 @@ after_frag( fd_net_ctx_t * ctx,
send_arp_probe( ctx, next_hop, if_idx );

/* refresh tables */
now = fd_log_wallclock();
ctx->ip_next_upd = now + (long)200e3;
ctx->next_netlink_refresh = fd_tickcount() + (long)( 200e3 * fd_tempo_tick_per_ns( NULL ) );
break;
case FD_IP_NO_ROUTE:
/* cannot make progress here */
Expand All @@ -482,8 +494,7 @@ after_frag( fd_net_ctx_t * ctx,
break;
case FD_IP_RETRY:
/* refresh tables */
now = fd_log_wallclock();
ctx->ip_next_upd = now + (long)200e3;
ctx->next_netlink_refresh = fd_tickcount() + (long)( 200e3 * fd_tempo_tick_per_ns( NULL ) );
/* TODO consider buffering */
break;
case FD_IP_MULTICAST:
Expand Down Expand Up @@ -608,6 +619,10 @@ privileged_init( fd_topo_t * topo,
}

ctx->ip = fd_ip_join( fd_ip_new( FD_SCRATCH_ALLOC_APPEND( l, fd_ip_align(), fd_ip_footprint( 0UL, 0UL ) ), 0UL, 0UL ) );

double tick_per_ns = fd_tempo_tick_per_ns( NULL );
ctx->netlink_refresh_interval_ticks = (long)( FD_NETLINK_REFRESH_INTERVAL_NS * tick_per_ns );
ctx->xdp_stats_interval_ticks = (long)( FD_XDP_STATS_INTERVAL_NS * tick_per_ns );
}

static void
Expand Down
10 changes: 9 additions & 1 deletion src/app/fddev/Local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ include src/app/fdctl/with-version.mk
.PHONY: fddev run monitor

# fddev core
$(call add-objs,main1 dev dev1 txn bench load dump flame wksp,fd_fddev)
$(call add-objs,main1 help wksp,fd_fddev)

# fddev actions
$(call add-objs,bench,fd_fddev)
$(call add-objs,dev dev1,fd_fddev)
$(call add-objs,dump,fd_fddev)
$(call add-objs,flame,fd_fddev)
$(call add-objs,load,fd_fddev)
$(call add-objs,txn,fd_fddev)

# fddev tiles
$(call add-objs,tiles/fd_bencho,fd_fddev)
Expand Down
11 changes: 9 additions & 2 deletions src/app/fddev/fddev.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "../fdctl/fdctl.h"

int fddev_main( int argc,
char ** argv );
extern action_t DEV_ACTIONS[];

int
fddev_main( int argc,
char ** argv );

void
update_config_for_dev( config_t * const config );
Expand Down Expand Up @@ -131,4 +134,8 @@ void
quic_trace_cmd_fn( args_t * args,
config_t * const config );

void
dev_help_cmd_fn( args_t * args,
config_t * const config );

#endif /* HEADER_fd_src_app_fddev_fddev_h */
25 changes: 25 additions & 0 deletions src/app/fddev/help.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "fddev.h"

void
dev_help_cmd_fn( args_t * args FD_FN_UNUSED,
config_t * const config FD_FN_UNUSED ) {
FD_LOG_STDOUT(( "Firedancer development binary\n\n" ));
FD_LOG_STDOUT(( "Usage: fddev [OPTIONS] <SUBCOMMAND>\n\n" ));
FD_LOG_STDOUT(( "\nOPTIONS:\n" ));
/* fddev does not have many flag arguments so we hard-code the
--config parameter. */
FD_LOG_STDOUT(( " --config <PATH> Path to config TOML file\n\n" ));

FD_LOG_STDOUT(( "SUBCOMMANDS (fddev):\n" ));
for( ulong i=0; DEV_ACTIONS[ i ].name; i++ ) {
FD_LOG_STDOUT(( " %10s %s\n", DEV_ACTIONS[ i ].name, DEV_ACTIONS[ i ].description ));
}

FD_LOG_STDOUT(( "\nSUBCOMMANDS (fdctl):\n" ));
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
for( ulong j=0; DEV_ACTIONS[ j ].name; j++ ) {
if( 0==strcmp( ACTIONS[ i ].name, DEV_ACTIONS[ j ].name ) ) break;
}
FD_LOG_STDOUT(( " %10s %s\n", ACTIONS[ i ].name, ACTIONS[ i ].description ));
}
}
26 changes: 14 additions & 12 deletions src/app/fddev/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ fd_topo_run_tile_t * TILES[] = {
NULL,
};

static action_t DEV_ACTIONS[] = {
{ .name = "dev", .args = dev_cmd_args, .fn = dev_cmd_fn, .perm = dev_cmd_perm },
{ .name = "wksp", .args = NULL, .fn = wksp_cmd_fn, .perm = wksp_cmd_perm },
{ .name = "dev1", .args = dev1_cmd_args, .fn = dev1_cmd_fn, .perm = dev_cmd_perm },
{ .name = "txn", .args = txn_cmd_args, .fn = txn_cmd_fn, .perm = txn_cmd_perm },
{ .name = "bench", .args = bench_cmd_args, .fn = bench_cmd_fn, .perm = bench_cmd_perm },
{ .name = "load", .args = load_cmd_args, .fn = load_cmd_fn, .perm = load_cmd_perm },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL, .is_diagnostic=1 },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm, .is_diagnostic=1 },
{ .name = "quic-trace", .args = quic_trace_cmd_args, .fn = quic_trace_cmd_fn, .perm = NULL, .is_diagnostic=1 },
action_t DEV_ACTIONS[] = {
{ .name = "bench", .args = bench_cmd_args, .fn = bench_cmd_fn, .perm = bench_cmd_perm, .description = "Test validator TPS benchmark" },
{ .name = "dev", .args = dev_cmd_args, .fn = dev_cmd_fn, .perm = dev_cmd_perm, .description = "Start up a test validator" },
{ .name = "dev1", .args = dev1_cmd_args, .fn = dev1_cmd_fn, .perm = dev_cmd_perm, .description = "Start up a single tile" },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL, .description = "Dump tango links to pcap", .is_diagnostic=1 },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm, .description = "Capture a perf flamegraph", .is_diagnostic=1 },
{ .name = "help", .args = NULL, .fn = dev_help_cmd_fn, .perm = NULL, .description = "Print this help message", .is_diagnostic=1 },
{ .name = "load", .args = load_cmd_args, .fn = load_cmd_fn, .perm = load_cmd_perm, .description = "Load test an external validator" },
{ .name = "quic-trace", .args = quic_trace_cmd_args, .fn = quic_trace_cmd_fn, .perm = NULL, .description = "Trace quic tile", .is_diagnostic=1 },
{ .name = "txn", .args = txn_cmd_args, .fn = txn_cmd_fn, .perm = txn_cmd_perm, .description = "Send a transaction to an fddev instance" },
{ .name = "wksp", .args = NULL, .fn = wksp_cmd_fn, .perm = wksp_cmd_perm, .description = "Initialize workspaces" },
{0}
};

extern char fd_log_private_path[ 1024 ];
Expand Down Expand Up @@ -187,13 +189,13 @@ fddev_main( int argc,
}

action_t * action = NULL;
for( ulong i=0; i<sizeof(ACTIONS)/sizeof(ACTIONS[ 0 ]); i++ ) {
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( action_name, ACTIONS[ i ].name ) ) ) {
action = &ACTIONS[ i ];
break;
}
}
for( ulong i=0; i<sizeof(DEV_ACTIONS)/sizeof(DEV_ACTIONS[ 0 ]); i++ ) {
for( ulong i=0; DEV_ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( action_name, DEV_ACTIONS[ i ].name ) ) ) {
action = &DEV_ACTIONS[ i ];
break;
Expand Down
Loading