LCOV - differential code coverage report
Current view: top level - pageserver/src/tenant/secondary - heatmap.rs (source / functions) Coverage Total Hit UBC CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 100.0 % 20 20 20
Current Date: 2024-01-09 02:06:09 Functions: 50.0 % 42 21 21 21
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           TLA  Line data    Source code
       1                 : use std::time::SystemTime;
       2                 : 
       3                 : use crate::tenant::{
       4                 :     remote_timeline_client::index::IndexLayerMetadata, storage_layer::LayerFileName,
       5                 : };
       6                 : 
       7                 : use serde::{Deserialize, Serialize};
       8                 : use serde_with::{serde_as, DisplayFromStr, TimestampSeconds};
       9                 : 
      10                 : use utils::{generation::Generation, id::TimelineId};
      11                 : 
      12 CBC          30 : #[derive(Serialize, Deserialize)]
      13                 : pub(super) struct HeatMapTenant {
      14                 :     /// Generation of the attached location that uploaded the heatmap: this is not required
      15                 :     /// for correctness, but acts as a hint to secondary locations in order to detect thrashing
      16                 :     /// in the unlikely event that two attached locations are both uploading conflicting heatmaps.
      17                 :     pub(super) generation: Generation,
      18                 : 
      19                 :     pub(super) timelines: Vec<HeatMapTimeline>,
      20                 : }
      21                 : 
      22                 : #[serde_as]
      23              36 : #[derive(Serialize, Deserialize)]
      24                 : pub(crate) struct HeatMapTimeline {
      25                 :     #[serde_as(as = "DisplayFromStr")]
      26                 :     pub(super) timeline_id: TimelineId,
      27                 : 
      28                 :     pub(super) layers: Vec<HeatMapLayer>,
      29                 : }
      30                 : 
      31                 : #[serde_as]
      32           29352 : #[derive(Serialize, Deserialize)]
      33                 : pub(crate) struct HeatMapLayer {
      34                 :     pub(super) name: LayerFileName,
      35                 :     pub(super) metadata: IndexLayerMetadata,
      36                 : 
      37                 :     #[serde_as(as = "TimestampSeconds<i64>")]
      38                 :     pub(super) access_time: SystemTime,
      39                 :     // TODO: an actual 'heat' score that would let secondary locations prioritize downloading
      40                 :     // the hottest layers, rather than trying to simply mirror whatever layers are on-disk on the primary.
      41                 : }
      42                 : 
      43                 : impl HeatMapLayer {
      44            2453 :     pub(crate) fn new(
      45            2453 :         name: LayerFileName,
      46            2453 :         metadata: IndexLayerMetadata,
      47            2453 :         access_time: SystemTime,
      48            2453 :     ) -> Self {
      49            2453 :         Self {
      50            2453 :             name,
      51            2453 :             metadata,
      52            2453 :             access_time,
      53            2453 :         }
      54            2453 :     }
      55                 : }
      56                 : 
      57                 : impl HeatMapTimeline {
      58               6 :     pub(crate) fn new(timeline_id: TimelineId, layers: Vec<HeatMapLayer>) -> Self {
      59               6 :         Self {
      60               6 :             timeline_id,
      61               6 :             layers,
      62               6 :         }
      63               6 :     }
      64                 : }
        

Generated by: LCOV version 2.1-beta