LCOV - code coverage report
Current view: top level - pageserver/src - l0_flush.rs (source / functions) Coverage Total Hit
Test: 98683a8629f0f7f0031d02e04512998d589d76ea.info Lines: 70.8 % 24 17
Test Date: 2025-04-11 16:58:57 Functions: 75.0 % 4 3

            Line data    Source code
       1              : use std::num::NonZeroUsize;
       2              : use std::sync::Arc;
       3              : 
       4              : #[derive(Debug, PartialEq, Eq, Clone)]
       5              : pub enum L0FlushConfig {
       6              :     Direct { max_concurrency: NonZeroUsize },
       7              : }
       8              : 
       9              : impl Default for L0FlushConfig {
      10          956 :     fn default() -> Self {
      11          956 :         Self::Direct {
      12          956 :             // TODO: using num_cpus results in different peak memory usage on different instance types.
      13          956 :             max_concurrency: NonZeroUsize::new(usize::max(1, num_cpus::get())).unwrap(),
      14          956 :         }
      15          956 :     }
      16              : }
      17              : 
      18              : impl From<pageserver_api::models::L0FlushConfig> for L0FlushConfig {
      19            0 :     fn from(config: pageserver_api::models::L0FlushConfig) -> Self {
      20            0 :         match config {
      21            0 :             pageserver_api::models::L0FlushConfig::Direct { max_concurrency } => {
      22            0 :                 Self::Direct { max_concurrency }
      23            0 :             }
      24            0 :         }
      25            0 :     }
      26              : }
      27              : 
      28              : #[derive(Clone)]
      29              : pub struct L0FlushGlobalState(Arc<Inner>);
      30              : 
      31              : pub enum Inner {
      32              :     Direct { semaphore: tokio::sync::Semaphore },
      33              : }
      34              : 
      35              : impl L0FlushGlobalState {
      36          460 :     pub fn new(config: L0FlushConfig) -> Self {
      37          460 :         match config {
      38          460 :             L0FlushConfig::Direct { max_concurrency } => {
      39          460 :                 let semaphore = tokio::sync::Semaphore::new(max_concurrency.get());
      40          460 :                 Self(Arc::new(Inner::Direct { semaphore }))
      41          460 :             }
      42          460 :         }
      43          460 :     }
      44              : 
      45         1936 :     pub fn inner(&self) -> &Arc<Inner> {
      46         1936 :         &self.0
      47         1936 :     }
      48              : }
        

Generated by: LCOV version 2.1-beta