LCOV - code coverage report
Current view: top level - vinyl/line - fd_vinyl_line.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 19 49 38.8 %
Date: 2025-12-07 04:58:33 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #include "fd_vinyl_line.h"
       2             : 
       3             : void
       4             : fd_vinyl_line_evict_prio( uint *            _line_idx_lru,
       5             :                           fd_vinyl_line_t * line,
       6             :                           ulong             _line_cnt,
       7             :                           ulong             _line_idx,
       8     3000000 :                           int               evict_prio ) {
       9             : 
      10     3000000 :   if( FD_UNLIKELY( evict_prio>=FD_VINYL_LINE_EVICT_PRIO_UNC ) ) return; /* no-op */
      11             : 
      12     2248794 :   uint line_cnt = (uint)_line_cnt;
      13     2248794 :   uint line_idx = (uint)_line_idx;
      14             : 
      15             :   /* Remove line_idx from its current position in the eviction sequence */
      16             : 
      17     2248794 :   uint line_idx_lru   = *_line_idx_lru;
      18     2248794 :   uint line_idx_newer = line[ line_idx ].line_idx_newer; uint line_idx_older = line[ line_idx ].line_idx_older;
      19             : 
      20     2248794 :   FD_CRIT( line_idx_lru  <line_cnt, "corruption detected" );
      21     2248794 :   FD_CRIT( line_idx_newer<line_cnt, "corruption detected" );
      22     2248794 :   FD_CRIT( line_idx_older<line_cnt, "corruption detected" );
      23             : 
      24     2248794 :   line[ line_idx_newer ].line_idx_older = line_idx_older;
      25     2248794 :   line[ line_idx_older ].line_idx_newer = line_idx_newer;
      26             : 
      27     2248794 :   line_idx_lru = fd_uint_if( line_idx_lru!=line_idx, line_idx_lru, line_idx_newer );
      28             : 
      29             :   /* Insert line_idx between the LRU and MRU in the eviction sequence */
      30             : 
      31     2248794 :   line_idx_newer =       line_idx_lru;
      32     2248794 :   line_idx_older = line[ line_idx_lru ].line_idx_older;
      33             : 
      34     2248794 :   FD_CRIT( line_idx_older<line_cnt, "corruption detected" );
      35             : 
      36     2248794 :   line[ line_idx_newer ].line_idx_older = line_idx; line[ line_idx ].line_idx_newer = line_idx_newer;
      37     2248794 :   line[ line_idx_older ].line_idx_newer = line_idx; line[ line_idx ].line_idx_older = line_idx_older;
      38             : 
      39             :   /* Update the LRU */
      40             : 
      41     2248794 :   *_line_idx_lru = fd_uint_if( evict_prio==FD_VINYL_LINE_EVICT_PRIO_LRU, line_idx, line_idx_lru );
      42     2248794 : }
      43             : 
      44             : ulong
      45             : fd_vinyl_line_evict_lru( uint *                _line_idx_lru,
      46             :                          fd_vinyl_line_t *     line,
      47             :                          ulong                 line_cnt,
      48             :                          fd_vinyl_meta_ele_t * ele0,
      49             :                          ulong                 ele_max,
      50           0 :                          fd_vinyl_data_t *     data ) {
      51             : 
      52           0 :   ulong line_idx = (ulong)*_line_idx_lru;
      53             : 
      54           0 :   ulong rem;
      55             : 
      56           0 :   for( rem=line_cnt; rem; rem-- ) {
      57             : 
      58           0 :     FD_CRIT( line_idx<line_cnt, "corruption detected" );
      59             : 
      60           0 :     ulong line_ctl = line[ line_idx ].ctl;
      61             : 
      62           0 :     if( FD_LIKELY( !fd_vinyl_line_ctl_ref( line_ctl ) ) ) {
      63             : 
      64           0 :       fd_vinyl_data_obj_t * obj     = line[ line_idx ].obj;
      65           0 :       ulong                 ele_idx = line[ line_idx ].ele_idx;
      66             : 
      67           0 :       if( FD_LIKELY( obj ) ) {
      68           0 :         FD_CRIT( obj->line_idx==line_idx, "corruption detected" );
      69           0 :         FD_CRIT( !obj->rd_active,         "corruption detected" );
      70           0 :         fd_vinyl_data_free( data, obj );
      71           0 :         line[ line_idx ].obj = NULL;
      72           0 :       }
      73             : 
      74           0 :       if( FD_LIKELY( ele_idx<ele_max ) ) {
      75           0 :         FD_CRIT( ele0[ ele_idx ].line_idx==line_idx, "corruption detected" );
      76           0 :         ele0[ ele_idx ].line_idx = ULONG_MAX;
      77           0 :       } else {
      78           0 :         FD_CRIT( ele_idx==ULONG_MAX, "corruption detected" );
      79           0 :       }
      80             : 
      81           0 :       ulong ver = fd_vinyl_line_ctl_ver( line_ctl );
      82           0 :       line[ line_idx ].ctl = fd_vinyl_line_ctl( ver+1UL, 0L ); /* bump ver */
      83             : 
      84           0 :       break;
      85           0 :     }
      86             : 
      87           0 :     line_idx = (ulong)line[ line_idx ].line_idx_newer;
      88             : 
      89           0 :   }
      90             : 
      91           0 :   FD_CRIT( rem, "corruption detected" );
      92             : 
      93           0 :   return line_idx;
      94           0 : }

Generated by: LCOV version 1.14