mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
Merge branch 'pddb-flamegraph' into main
This commit is contained in:
commit
826aa43f20
5 changed files with 104 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2366,6 +2366,7 @@ dependencies = [
|
|||
"cipher 0.4.3",
|
||||
"digest 0.9.0",
|
||||
"gam",
|
||||
"hex 0.4.3",
|
||||
"hkdf",
|
||||
"llio",
|
||||
"locales",
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ utralib = { path = "../../utralib"}
|
|||
rand = "0.7.3"
|
||||
rand_chacha = "0.3.1"
|
||||
|
||||
hex = { version = "0.4.3", default-features = false, features = ["alloc"], optional = true }
|
||||
|
||||
[features]
|
||||
# when selected, physical disk addresses are set to 64 bits, otherwise, they are 32 bits.
|
||||
# 32 bit addressing is recommended for Precursor, as its disk is only 128MiB and it has limited RAM for bookkeeping.
|
||||
|
|
@ -76,4 +78,6 @@ migration1 = []
|
|||
# hazardous debug flag decorates any debug paths that might accidentally leak key material
|
||||
hazardous-debug = []
|
||||
test-rekey = []
|
||||
default = ["mbbb"]
|
||||
# routines to help with performance profiling of the PDDB in hosted mode
|
||||
pddb-flamegraph = ["hex"]
|
||||
default = ["mbbb", "pddb-flamegraph"]
|
||||
|
|
|
|||
|
|
@ -381,6 +381,9 @@ mod tests;
|
|||
#[allow(unused_imports)]
|
||||
use tests::*;
|
||||
|
||||
#[cfg(feature="pddb-flamegraph")]
|
||||
mod profiling;
|
||||
|
||||
use num_traits::*;
|
||||
use xous::{send_message, Message, msg_blocking_scalar_unpack};
|
||||
use xous_ipc::Buffer;
|
||||
|
|
@ -663,6 +666,8 @@ fn wrapped_main() -> ! {
|
|||
latest_cache = basis_cache.cache_size();
|
||||
log::info!("PDDB post-mount caching stats: {} heap, {} cache", latest_heap, latest_cache);
|
||||
scrub_run.store(true, Ordering::SeqCst);
|
||||
#[cfg(feature="pddb-flamegraph")]
|
||||
profiling::do_query_work();
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
|
|
|||
66
services/pddb/src/profiling.rs
Normal file
66
services/pddb/src/profiling.rs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
use std::thread;
|
||||
#[allow(unused_imports)]
|
||||
use std::io::{Error, ErrorKind, Write, Read};
|
||||
|
||||
const PROFILING_DICT: &'static str = "pdict";
|
||||
const NUMKEYS: usize = 200;
|
||||
const PROFILE_ITERS: usize = 200;
|
||||
|
||||
fn gen_guid(trng: &mut trng::Trng) -> String {
|
||||
let mut guid = [0u8; 16];
|
||||
trng.fill_bytes(&mut guid);
|
||||
hex::encode(guid)
|
||||
}
|
||||
|
||||
/// A test that repeatedly queries a dictionary with many entries
|
||||
pub fn do_query_work() {
|
||||
let _ = thread::spawn(|| {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let pddb = pddb::Pddb::new();
|
||||
let mut trng = trng::Trng::new(&xns).unwrap();
|
||||
|
||||
let key_count = match pddb.list_keys(PROFILING_DICT, None) {
|
||||
Ok(kl) => kl.len(),
|
||||
Err(_e) => {
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
// populate the dictionary if we're short the number of keys we want to have
|
||||
log::info!("test setup");
|
||||
if key_count < NUMKEYS {
|
||||
for _ in 0..NUMKEYS - key_count {
|
||||
let guid = gen_guid(&mut trng);
|
||||
match pddb.get(
|
||||
PROFILING_DICT,
|
||||
&guid,
|
||||
None,
|
||||
true,
|
||||
true,
|
||||
Some(256),
|
||||
None::<fn()>
|
||||
) {
|
||||
Ok(mut key) => {
|
||||
let mut rdata = [0u8; 192];
|
||||
trng.fill_bytes(&mut rdata);
|
||||
key.write_all(&rdata).ok();
|
||||
}
|
||||
Err(e) => log::error!("couldn't create test key {:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
log::info!("starting main loop");
|
||||
let modals = modals::Modals::new(&xns).unwrap();
|
||||
modals.show_notification("press any key to start profiling run.", None).ok();
|
||||
|
||||
modals.dynamic_notification(Some("running"), None).ok();
|
||||
for i in 0..PROFILE_ITERS {
|
||||
let klist = pddb.list_keys(PROFILING_DICT, None).unwrap();
|
||||
log::info!("iter {}, klist: {}", i, klist.len());
|
||||
}
|
||||
modals.dynamic_notification_close().ok();
|
||||
modals.show_notification("done", None).ok();
|
||||
|
||||
log::info!("quitting");
|
||||
});
|
||||
}
|
||||
|
|
@ -382,6 +382,33 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
Some(&["--features", "renode-bypass"]),
|
||||
)?;
|
||||
}
|
||||
Some("pddb-flamegraph") => {
|
||||
let mut args = env::args();
|
||||
args.nth(1);
|
||||
let mut pkgs = pddb_dev_pkgs.to_vec();
|
||||
// add pkgs required for functional testing. Quite a bit. :-/
|
||||
pkgs.push("llio");
|
||||
pkgs.push("root-keys");
|
||||
pkgs.push("jtag");
|
||||
pkgs.push("com");
|
||||
pkgs.push("gam");
|
||||
pkgs.push("net");
|
||||
pkgs.push("dns");
|
||||
pkgs.push("graphics-server");
|
||||
pkgs.push("modals");
|
||||
pkgs.push("keyboard");
|
||||
pkgs.push("ime-frontend");
|
||||
pkgs.push("ime-plugin-shell");
|
||||
pkgs.push("status");
|
||||
pkgs.push("usb-device-xous");
|
||||
generate_app_menus(&vec![]);
|
||||
run(false, &pkgs,
|
||||
Some(&[
|
||||
"--features", "pddbtest",
|
||||
"--features", "pddb-flamegraph",
|
||||
]), false)?
|
||||
|
||||
}
|
||||
Some("renode-aes-test") => {
|
||||
generate_app_menus(&Vec::<String>::new());
|
||||
renode_image(false, &aestest_pkgs, &[], None, None)?
|
||||
|
|
|
|||
Loading…
Reference in a new issue