From 916ca5f062c74caddfd06a985bca5a339580daff Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 28 Mar 2024 16:16:45 +0800 Subject: [PATCH] use auto-release API and note benchmark results --- services/shellchat/Cargo.toml | 5 +++-- services/shellchat/src/cmds/engine.rs | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index 294d1d594..0b6861447 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -100,8 +100,9 @@ random-pick = { version = "1.2.16", optional = true } hex = { version = "0.4.3", default-features = false, features = [] } #sha2 = {version = "0.9.5", default-features = false, features = []} [dependencies.curve25519-dalek] -version = "=4.1.2" # note this is patched to our fork in ./Cargo.toml +version = "=4.1.2" # note this is patched to our fork in ./Cargo.toml default-features = false +features = ["auto-release", "warn-fallback"] [dependencies.x25519-dalek] version = "=2.0.1" @@ -152,4 +153,4 @@ rand-api = [] locktests = [ ] # for debugging some specific `std` tests cherry-picked out of the test suite simple-tls = ["rustls", "webpki-roots"] -default = [] # "debugprint" +default = ["benchmarks"] # "debugprint" diff --git a/services/shellchat/src/cmds/engine.rs b/services/shellchat/src/cmds/engine.rs index f6c5379d0..055104992 100644 --- a/services/shellchat/src/cmds/engine.rs +++ b/services/shellchat/src/cmds/engine.rs @@ -41,7 +41,9 @@ fn vector_read(word_offset: usize) -> u32 { fn run_vectors() -> (usize, usize) { use curve25519_dalek::backend::serial::u32e::*; - ensure_engine(); + while ensure_engine().is_err() { + xous::yield_slice(); + } // safety: it's safe because it's after ensure_engine() let ucode_hw = unsafe { get_ucode() }; let rf_hw = unsafe { get_rf() }; @@ -116,6 +118,10 @@ benchmark notes: +59mA +/-1mA current draw off fully charged battery when running the benchmark 1246-1261ms/check vector iteration (10 iters total, 1450 vectors total) + +With new curve25519 api: +53.6ms/check vector iteration (10 iters total, 1450 vectors total) with engine retained +56.5ms/check with auto-free */ pub fn benchmark_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { let sid = xous::SID::from_u32(sid0 as u32, sid1 as u32, sid2 as u32, sid3 as u32); @@ -160,6 +166,9 @@ pub fn benchmark_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { 13.54ms/2xop (200 iters -hw) -- microcode pre-loaded, minimal registers transferred using MontgomeryJob call 12.2ms/2xop (200 iters -hw) -- with L2 cache on (128k) 12.29ms/2xop (200 iters -hw) -- with L2 cache on (64k) + + 8.37ms/2xop (200 iters - hw) - with new curve25519 lib and engine retained after every loop + 33.04ms/2xop (200 iters - hw) - with new curve25519 lib and auto-free engine after every loop */ Some(BenchOp::StartDh) => { let mut passes = 0;