LCOV - code coverage report
Current view: top level - app/fdctl - config.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 95 114 83.3 %
Date: 2025-03-20 12:08:36 Functions: 4 5 80.0 %

          Line data    Source code
       1             : #define _GNU_SOURCE
       2             : 
       3             : #include "fdctl.h"
       4             : 
       5             : #include "../../disco/topo/fd_pod_format.h"
       6             : #include "../../disco/metrics/fd_metrics.h"
       7             : #include "../../disco/keyguard/fd_keyswitch.h"
       8             : #if FD_HAS_NO_AGAVE
       9             : #include "../../flamenco/runtime/fd_blockstore.h"
      10             : #include "../../flamenco/runtime/fd_txncache.h"
      11             : #include "../../flamenco/runtime/fd_runtime.h"
      12             : #endif
      13             : #include "../../funk/fd_funk.h"
      14             : #include "../../waltz/ip/fd_fib4.h"
      15             : #include "../../waltz/mib/fd_dbl_buf.h"
      16             : #undef FD_MAP_FLAG_BLOCKING
      17             : #include "../../waltz/neigh/fd_neigh4_map.h"
      18             : 
      19             : fd_topo_run_tile_t *
      20         216 : fd_topo_tile_to_config( fd_topo_tile_t const * tile ) {
      21         216 :   fd_topo_run_tile_t ** run = TILES;
      22        2448 :   while( *run ) {
      23        2448 :     if( FD_LIKELY( !strcmp( (*run)->name, tile->name ) ) ) return *run;
      24        2232 :     run++;
      25        2232 :   }
      26           0 :   FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));
      27           0 : }
      28             : 
      29             : ulong
      30             : fdctl_obj_align( fd_topo_t const *     topo,
      31         582 :                  fd_topo_obj_t const * obj ) {
      32         582 :   if( FD_UNLIKELY( !strcmp( obj->name, "tile" ) ) ) {
      33          72 :     fd_topo_tile_t const * tile = NULL;
      34         900 :     for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
      35         900 :       if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
      36          72 :         tile = &topo->tiles[ i ];
      37          72 :         break;
      38          72 :       }
      39         900 :     }
      40          72 :     fd_topo_run_tile_t * config = fd_topo_tile_to_config( tile );
      41          72 :     if( FD_LIKELY( config->scratch_align ) ) return config->scratch_align();
      42           0 :     return 1UL;
      43         510 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "mcache" ) ) ) {
      44         117 :     return fd_mcache_align();
      45         393 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "dcache" ) ) ) {
      46         111 :     return fd_dcache_align();
      47         282 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "cnc" ) ) ) {
      48           0 :     return fd_cnc_align();
      49         282 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "fseq" ) ) ) {
      50         183 :     return fd_fseq_align();
      51         183 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "metrics" ) ) ) {
      52          72 :     return FD_METRICS_ALIGN;
      53          72 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "opaque" ) ) ) {
      54           3 :     ulong align = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.align", obj->id );
      55           3 :     if( FD_UNLIKELY( align==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.align was not set", obj->id ));
      56           3 :     return align;
      57          24 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "dbl_buf" ) ) ) {
      58           3 :     return fd_dbl_buf_align();
      59          21 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "funk" ) ) ) {
      60           0 :     return fd_funk_align();
      61          21 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "neigh4_hmap" ) ) ) {
      62           3 :     return fd_neigh4_hmap_align();
      63          18 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "fib4" ) ) ) {
      64           6 :     return fd_fib4_align();
      65          12 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "keyswitch" ) ) ) {
      66          12 :     return fd_keyswitch_align();
      67             : #if FD_HAS_NO_AGAVE
      68             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "replay_pub" ) ) ) {
      69             :     return fd_runtime_public_align();
      70             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "blockstore" ) ) ) {
      71             :     return fd_blockstore_align();
      72             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "txncache" ) ) ) {
      73             :     return fd_txncache_align();
      74             : #endif /* FD_HAS_NO_AGAVE */
      75          12 :   } else {
      76           0 :     FD_LOG_ERR(( "unknown object `%s`", obj->name ));
      77           0 :     return 0UL;
      78           0 :   }
      79         582 : }
      80             : 
      81             : ulong
      82             : fdctl_obj_footprint( fd_topo_t const *     topo,
      83         582 :                      fd_topo_obj_t const * obj ) {
      84         582 :   #define VAL(name) (__extension__({                                                               \
      85         471 :       ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name );      \
      86         471 :       if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
      87         471 :       __x; }))
      88             : 
      89         582 :   if( FD_UNLIKELY( !strcmp( obj->name, "tile" ) ) ) {
      90          72 :     fd_topo_tile_t const * tile = NULL;
      91         900 :     for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
      92         900 :       if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
      93          72 :         tile = &topo->tiles[ i ];
      94          72 :         break;
      95          72 :       }
      96         900 :     }
      97          72 :     fd_topo_run_tile_t * config = fd_topo_tile_to_config( tile );
      98          72 :     if( FD_LIKELY( config->scratch_footprint ) ) return config->scratch_footprint( tile );
      99           0 :     return 0UL;
     100         510 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "mcache" ) ) ) {
     101         117 :     return fd_mcache_footprint( VAL("depth"), 0UL );
     102         393 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "dcache" ) ) ) {
     103         111 :     return fd_dcache_footprint( fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1), 0UL );
     104         282 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "cnc" ) ) ) {
     105           0 :     return fd_cnc_footprint( 0UL );
     106         282 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "fseq" ) ) ) {
     107         183 :     return fd_fseq_footprint();
     108         183 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "metrics" ) ) ) {
     109          72 :     return FD_METRICS_FOOTPRINT( VAL("in_cnt"), VAL("cons_cnt") );
     110          72 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "opaque" ) ) ) {
     111           3 :     return VAL("footprint");
     112          24 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "dbl_buf" ) ) ) {
     113           3 :     return fd_dbl_buf_footprint( VAL("mtu") );
     114          21 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "funk" ) ) ) {
     115           0 :     return fd_funk_footprint();
     116          21 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "neigh4_hmap" ) ) ) {
     117           3 :     return fd_neigh4_hmap_footprint( VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max") );
     118          18 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "fib4" ) ) ) {
     119           6 :     return fd_fib4_footprint( VAL("route_max") );
     120          12 :   } else if( FD_UNLIKELY( !strcmp( obj->name, "keyswitch" ) ) ) {
     121          12 :     return fd_keyswitch_footprint();
     122             : #if FD_HAS_NO_AGAVE
     123             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "replay_pub" ) ) ) {
     124             :     return fd_runtime_public_footprint();
     125             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "blockstore" ) ) ) {
     126             :     return fd_blockstore_footprint( VAL("shred_max"), VAL("block_max"), VAL("idx_max"), VAL("txn_max") ) + VAL("alloc_max");
     127             :   } else if( FD_UNLIKELY( !strcmp( obj->name, "txncache" ) ) ) {
     128             :     return fd_txncache_footprint( VAL("max_rooted_slots"), VAL("max_live_slots"), VAL("max_txn_per_slot"), FD_TXNCACHE_DEFAULT_MAX_CONSTIPATED_SLOTS );
     129             : #endif /* FD_HAS_NO_AGAVE */
     130          12 :   } else {
     131           0 :     FD_LOG_ERR(( "unknown object `%s`", obj->name ));
     132           0 :     return 0UL;
     133           0 :   }
     134         582 : #undef VAL
     135         582 : }
     136             : 
     137             : ulong
     138             : fdctl_obj_loose( fd_topo_t const *     topo,
     139         582 :                  fd_topo_obj_t const * obj ) {
     140         582 :   ulong loose = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, "loose" );
     141         582 :   if( loose!=ULONG_MAX ) {
     142           0 :     return loose;
     143           0 :   }
     144             : 
     145         582 :   if( FD_UNLIKELY( !strcmp( obj->name, "tile" ) ) ) {
     146          72 :     fd_topo_tile_t const * tile = NULL;
     147         900 :     for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     148         900 :       if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     149          72 :         tile = &topo->tiles[ i ];
     150          72 :         break;
     151          72 :       }
     152         900 :     }
     153          72 :     fd_topo_run_tile_t * config = fd_topo_tile_to_config( tile );
     154          72 :     if( FD_LIKELY( config->loose_footprint ) ) return config->loose_footprint( tile );
     155          72 :   }
     156         579 :   return 0UL;
     157         582 : }
     158             : 
     159             : fd_topo_run_tile_t
     160           0 : fdctl_tile_run( fd_topo_tile_t const * tile ) {
     161           0 :   return *fd_topo_tile_to_config( tile );
     162           0 : }

Generated by: LCOV version 1.14