LCOV - code coverage report
Current view: top level - pageserver/src - l0_flush.rs (source / functions) Coverage Total Hit
Test: ccf45ed1c149555259baec52d6229a81013dcd6a.info Lines: 94.4 % 18 17
Test Date: 2024-08-21 17:32:46 Functions: 20.0 % 15 3

            Line data    Source code
       1              : use std::{num::NonZeroUsize, sync::Arc};
       2              : 
       3            0 : #[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize)]
       4              : #[serde(tag = "mode", rename_all = "kebab-case", deny_unknown_fields)]
       5              : pub enum L0FlushConfig {
       6              :     #[serde(rename_all = "snake_case")]
       7              :     Direct { max_concurrency: NonZeroUsize },
       8              : }
       9              : 
      10              : impl Default for L0FlushConfig {
      11          394 :     fn default() -> Self {
      12          394 :         Self::Direct {
      13          394 :             // TODO: using num_cpus results in different peak memory usage on different instance types.
      14          394 :             max_concurrency: NonZeroUsize::new(usize::max(1, num_cpus::get())).unwrap(),
      15          394 :         }
      16          394 :     }
      17              : }
      18              : 
      19              : #[derive(Clone)]
      20              : pub struct L0FlushGlobalState(Arc<Inner>);
      21              : 
      22              : pub enum Inner {
      23              :     Direct { semaphore: tokio::sync::Semaphore },
      24              : }
      25              : 
      26              : impl L0FlushGlobalState {
      27          182 :     pub fn new(config: L0FlushConfig) -> Self {
      28          182 :         match config {
      29          182 :             L0FlushConfig::Direct { max_concurrency } => {
      30          182 :                 let semaphore = tokio::sync::Semaphore::new(max_concurrency.get());
      31          182 :                 Self(Arc::new(Inner::Direct { semaphore }))
      32          182 :             }
      33          182 :         }
      34          182 :     }
      35              : 
      36         1134 :     pub fn inner(&self) -> &Arc<Inner> {
      37         1134 :         &self.0
      38         1134 :     }
      39              : }
        

Generated by: LCOV version 2.1-beta