MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / incremental_flush

Function incremental_flush

nodedb/src/storage/checkpoint.rs:213–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

211
212 #[test]
213 fn incremental_flush() {
214 let config = CheckpointConfig {
215 flush_fraction: 0.10,
216 tick_interval: Duration::from_millis(0), // No delay for test.
217 ..Default::default()
218 };
219 let mut coord = CheckpointCoordinator::new(config);
220 coord.register_engine("sparse");
221 coord.register_engine("vector");
222
223 coord.mark_dirty("sparse", 100);
224 coord.mark_dirty("vector", 50);
225
226 let plan = coord.tick();
227 assert!(!plan.is_empty());
228 // Sparse: 10% of 100 = 10 pages.
229 let sparse_flush = plan.iter().find(|(e, _)| e == "sparse").unwrap().1;
230 assert_eq!(sparse_flush, 10);
231
232 // Record flush.
233 coord.record_flush("sparse", sparse_flush);
234 assert_eq!(
235 coord
236 .engines
237 .iter()
238 .find(|e| e.engine_name == "sparse")
239 .unwrap()
240 .dirty_pages,
241 90
242 );
243 }
244
245 #[test]
246 fn force_flush_over_threshold() {

Callers

nothing calls this directly

Calls 6

register_engineMethod · 0.80
mark_dirtyMethod · 0.80
record_flushMethod · 0.80
tickMethod · 0.45
findMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected