LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_cost_tracker_store.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 2 2 100.0 %
Date: 2026-10-16 04:29:28 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_cost_tracker_store_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_cost_tracker_store_h
       3             : 
       4             : #include "fd_cost_tracker.h"
       5             : 
       6             : /* fd_cost_tracker_store_t tracks the cost trackers of live banks.  A
       7             :    new fd_cost_tracker_t is acquired when a bank starts executing and is
       8             :    released when the bank is frozen or pruned.  The representation of
       9             :    the cost trackers is partially in-memory and partially on disk.
      10             :    Generally, the cost trackers are not expected to spill to disk and
      11             :    will only happen in degenerate network conditions.  The caller is
      12             :    expected to manage the lifetime of each cost tracker. */
      13             : 
      14         369 : #define FD_COST_TRACKER_FD          (123455)
      15        1650 : #define FD_COST_TRACKER_STORE_ALIGN (128UL)
      16             : 
      17             : struct fd_cost_tracker_store;
      18             : typedef struct fd_cost_tracker_store fd_cost_tracker_store_t;
      19             : 
      20             : FD_PROTOTYPES_BEGIN
      21             : 
      22             : /* fd_cost_tracker_store_align returns the alignment of a
      23             :    fd_cost_tracker_store_t struct. */
      24             : 
      25             : ulong
      26             : fd_cost_tracker_store_align( void );
      27             : 
      28             : /* fd_cost_tracker_store_footprint sizes the cost tracker store for a
      29             :    given max_live_slots and cache_cnt. */
      30             : 
      31             : ulong
      32             : fd_cost_tracker_store_footprint( ulong max_live_slots,
      33             :                                  ulong cache_cnt );
      34             : 
      35             : /* fd_cost_tracker_store_new creates a cost tracker store object. */
      36             : 
      37             : void *
      38             : fd_cost_tracker_store_new( void * shmem,
      39             :                            int    disk_fd,
      40             :                            ulong  max_live_slots,
      41             :                            ulong  cache_cnt,
      42             :                            ulong  bench_max_cost_per_block,
      43             :                            ulong  seed );
      44             : 
      45             : /* fd_cost_tracker_store_join joins a shared memory region that
      46             :    corresponds to a valid fd_cost_tracker_store_t struct. */
      47             : 
      48             : fd_cost_tracker_store_t *
      49             : fd_cost_tracker_store_join( void * shmem,
      50             :                             int    disk_fd );
      51             : 
      52             : /* fd_cost_tracker_store_new_fork releases old_fork_id (unless it is
      53             :    USHORT_MAX), then creates a new, empty cost tracker in the cost
      54             :    tracker store and returns its fork id.  Crashes if every cost tracker
      55             :    is in use. */
      56             : 
      57             : ushort
      58             : fd_cost_tracker_store_new_fork( fd_cost_tracker_store_t * store,
      59             :                                 ushort                    old_fork_id );
      60             : 
      61             : /* fd_cost_tracker_store_release releases the cost tracker of fork_id in
      62             :    the cost tracker store.  The cost tracker is "deleted".  Crashes if it
      63             :    is pinned. */
      64             : 
      65             : void
      66             : fd_cost_tracker_store_release( fd_cost_tracker_store_t * store,
      67             :                                ushort                    fork_id );
      68             : 
      69             : /* fd_cost_tracker_store_{pin,unpin} pin and unpin the cost tracker of
      70             :    fork_id in memory, reading it from disk if needed.  These two must be
      71             :    paired together and is the only way to safely read or write the cost
      72             :    tracker.  Pins nest.  _peek can be called safely while the cost
      73             :    tracker is pinned. */
      74             : 
      75             : fd_cost_tracker_t *
      76             : fd_cost_tracker_store_pin( fd_cost_tracker_store_t * store,
      77             :                            ushort                    fork_id );
      78             : 
      79             : void
      80             : fd_cost_tracker_store_unpin( fd_cost_tracker_store_t * store,
      81             :                              ushort                    fork_id );
      82             : 
      83             : /* fd_cost_tracker_store_peek returns the in-memory cost tracker of
      84             :    fork_id.  It does not modify the store, so another thread may call it
      85             :    while the cost tracker is pinned.  Crashes if the cost tracker is not
      86             :    in memory. */
      87             : 
      88             : fd_cost_tracker_t *
      89             : fd_cost_tracker_store_peek( fd_cost_tracker_store_t const * store,
      90             :                             ushort                          fork_id );
      91             : 
      92             : /* fd_cost_tracker_store_reset resets the cost tracker store.  This is
      93             :    not meant for production use and is for testing only. */
      94             : 
      95             : void
      96             : fd_cost_tracker_store_reset( fd_cost_tracker_store_t * store );
      97             : 
      98             : FD_PROTOTYPES_END
      99             : 
     100             : #endif /* HEADER_fd_src_flamenco_runtime_fd_cost_tracker_store_h */

Generated by: LCOV version 1.14