Skip to content

Commit

Permalink
Add hugetlbfs.max_page_size config option
Browse files Browse the repository at this point in the history
Allows running fdctl on cloud providers
  • Loading branch information
riptl authored and ripatel-fd committed Feb 9, 2025
1 parent 0f50f58 commit 8b7c5d8
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/app/fdctl/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ fdctl_cfg_from_env( int * pargc,
"%s/.huge",
config->hugetlbfs.mount_path ) );

ulong max_page_sz = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
if( FD_UNLIKELY( max_page_sz!=FD_SHMEM_HUGE_PAGE_SZ && max_page_sz!=FD_SHMEM_GIGANTIC_PAGE_SZ ) ) {
FD_LOG_ERR(( "[hugetlbfs.max_page_size] must be \"huge\" or \"gigantic\"" ));
}

replace( config->log.path, "{user}", config->user );
replace( config->log.path, "{name}", config->name );
if( FD_LIKELY( !strcmp( "auto", config->log.colorize ) ) ) config->log.colorize1 = 2;
Expand Down
1 change: 1 addition & 0 deletions src/app/fdctl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ typedef struct {
char gigantic_page_mount_path[ PATH_MAX ];
char huge_page_mount_path[ PATH_MAX ];
char mount_path[ PATH_MAX ];
char max_page_size[ 16 ];
} hugetlbfs;

struct {
Expand Down
6 changes: 6 additions & 0 deletions src/app/fdctl/config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,12 @@ dynamic_port_range = "8900-9000"
# writable by the Firedancer user.
mount_path = "/mnt/.fd"

# The largest supported page size on the system. Possible values
# are either "huge" (2MiB) or "gigantic" (1GiB). Larger sizes yield
# better performance. Smaller values may be required on virtualized
# environments like cloud providers.
max_page_size = "gigantic"

# Tiles are described in detail in the layout section above. While the
# layout configuration determines how many of each tile to place on
# which CPU core to create a functioning system, below is the individual
Expand Down
2 changes: 2 additions & 0 deletions src/app/fdctl/config_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ fdctl_pod_to_cfg( config_t * config,
CFG_POP ( uint, layout.exec_tile_count );

CFG_POP ( cstr, hugetlbfs.mount_path );
CFG_POP ( cstr, hugetlbfs.max_page_size );

CFG_POP ( cstr, tiles.net.interface );
CFG_POP ( cstr, tiles.net.xdp_mode );
Expand Down Expand Up @@ -462,6 +463,7 @@ fdctl_cfg_validate( config_t * cfg ) {
CFG_HAS_NON_ZERO ( layout.exec_tile_count );

CFG_HAS_NON_EMPTY( hugetlbfs.mount_path );
CFG_HAS_NON_EMPTY( hugetlbfs.max_page_size );

CFG_HAS_NON_EMPTY( tiles.net.xdp_mode );
CFG_HAS_POW2 ( tiles.net.xdp_rx_queue_size );
Expand Down
1 change: 1 addition & 0 deletions src/app/fdctl/run/topos/fd_firedancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fd_topo_initialize( config_t * config ) {
int enable_rpc = ( config->rpc.port != 0 );

fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );

/* topo, name */
fd_topob_wksp( topo, "net_shred" );
Expand Down
1 change: 1 addition & 0 deletions src/app/fdctl/run/topos/fd_frankendancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fd_topo_initialize( config_t * config ) {
ulong shred_tile_cnt = config->layout.shred_tile_count;

fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );

/* topo, name */
fd_topob_wksp( topo, "net_quic" );
Expand Down
1 change: 1 addition & 0 deletions src/app/fddev/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ load_cmd_fn( args_t * args,
args->load.connections = config->layout.quic_tile_count;

fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
add_bench_topo( topo,
args->load.affinity,
args->load.benchg,
Expand Down
2 changes: 2 additions & 0 deletions src/disco/topo/fd_topo.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ typedef struct fd_topo_t {

ulong agave_affinity_cnt;
ulong agave_affinity_cpu_idx[ FD_TILE_MAX ];

ulong max_page_size; /* 2^21 or 2^30 */
} fd_topo_t;

typedef struct {
Expand Down
5 changes: 4 additions & 1 deletion src/disco/topo/fd_topob.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fd_topob_new( void * mem,
if( FD_UNLIKELY( strlen( app_name )>=sizeof(topo->app_name) ) ) FD_LOG_ERR(( "app_name too long: %s", app_name ));
strncpy( topo->app_name, app_name, sizeof(topo->app_name) );

topo->max_page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;

return topo;
}

Expand Down Expand Up @@ -488,8 +490,9 @@ fd_topob_finish( fd_topo_t * topo,
with an extra align of padding incase gaddr_lo is not aligned. */
ulong total_wksp_footprint = fd_wksp_footprint( part_max, footprint + fd_topo_workspace_align() + loose_sz );

ulong page_sz = FD_SHMEM_GIGANTIC_PAGE_SZ;
ulong page_sz = topo->max_page_size;
if( FD_UNLIKELY( total_wksp_footprint < 4 * FD_SHMEM_HUGE_PAGE_SZ ) ) page_sz = FD_SHMEM_HUGE_PAGE_SZ;
if( FD_UNLIKELY( page_sz!=FD_SHMEM_HUGE_PAGE_SZ && page_sz!=FD_SHMEM_GIGANTIC_PAGE_SZ ) ) FD_LOG_ERR(( "invalid page_sz" ));

ulong wksp_aligned_footprint = fd_ulong_align_up( total_wksp_footprint, page_sz );

Expand Down

0 comments on commit 8b7c5d8

Please sign in to comment.