Compute how many pages to flush this tick.
(&self, config: &CheckpointConfig)
| 64 | |
| 65 | /// Compute how many pages to flush this tick. |
| 66 | pub fn pages_to_flush(&self, config: &CheckpointConfig) -> usize { |
| 67 | if self.dirty_pages >= config.force_flush_threshold { |
| 68 | // Over threshold: flush everything to prevent stalling. |
| 69 | self.dirty_pages |
| 70 | } else { |
| 71 | // Normal: flush a fraction. |
| 72 | let target = (self.dirty_pages as f64 * config.flush_fraction).ceil() as usize; |
| 73 | target.max(1).min(self.dirty_pages) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /// Record that pages were flushed. |
| 78 | pub fn record_flush(&mut self, count: usize) { |