add implemenation of the prune debug call

this allows us to trigger the cache prune manually, instead of
in response to memory backpressure only
This commit is contained in:
bunnie 2022-12-29 22:04:15 +08:00
parent 549e67fead
commit e25da3a720
3 changed files with 20 additions and 0 deletions

View file

@ -535,6 +535,7 @@ pub struct PddbDangerousDebug {
pub enum DebugRequest {
Dump = 0,
Remount = 1,
Prune = 2,
}
#[cfg(test)]

View file

@ -1018,6 +1018,18 @@ impl Pddb {
buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap())
.or(Err(Error::new(ErrorKind::Other, "Xous internal error"))).map(|_| ())
}
/// Forces a basis pruning, for testing the pruning and prune recovery code.
#[cfg(not(target_os = "xous"))]
pub fn dbg_prune(&self) -> Result<()> {
let ipc = PddbDangerousDebug {
request: DebugRequest::Prune,
dump_name: xous_ipc::String::new(),
};
let buf = Buffer::into_buf(ipc)
.or(Err(Error::new(ErrorKind::Other, "Xous internal error")))?;
buf.lend(self.conn, Opcode::DangerousDebug.to_u32().unwrap())
.or(Err(Error::new(ErrorKind::Other, "Xous internal error"))).map(|_| ())
}
#[cfg(all(feature="pddbtest", feature="autobasis"))]
pub fn basis_testing(&self, config: &[Option<bool>; 32]) {

View file

@ -1817,6 +1817,13 @@ fn wrapped_main() -> ! {
} else {
log::info!("remount failed");
}
},
DebugRequest::Prune => {
log::info!("initiating prune");
log::set_max_level(log::LevelFilter::Debug);
basis_cache.cache_prune(&mut pddb_os, 262144);
log::set_max_level(log::LevelFilter::Info);
log::info!("prune finished");
}
}
}