This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[benchmarks] add more benchmarks and some supporting functions
- Loading branch information
Showing
15 changed files
with
289 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...icrobenchmarks/benches/microbenchmarks.rs → ...ks/lucet-benchmarks/benches/benchmarks.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use criterion::Criterion; | ||
use lucet_runtime_internals::context::{Context, ContextHandle}; | ||
|
||
/// Time the initialization of a context. | ||
fn context_init(c: &mut Criterion) { | ||
extern "C" fn f() {} | ||
|
||
let mut stack = vec![0u64; 1024].into_boxed_slice(); | ||
|
||
c.bench_function("context_init", move |b| { | ||
b.iter(|| { | ||
let mut parent = ContextHandle::new(); | ||
ContextHandle::create_and_init( | ||
&mut *stack, | ||
&mut parent, | ||
f as *const extern "C" fn(), | ||
&[], | ||
) | ||
.unwrap(); | ||
}) | ||
}); | ||
} | ||
|
||
/// Time the swap from an already-initialized context to a guest function and back. | ||
fn context_swap_return(c: &mut Criterion) { | ||
extern "C" fn f() {} | ||
|
||
c.bench_function("context_swap_return", move |b| { | ||
b.iter_batched( | ||
|| { | ||
let mut stack = vec![0u64; 1024].into_boxed_slice(); | ||
let mut parent = ContextHandle::new(); | ||
let child = ContextHandle::create_and_init( | ||
&mut *stack, | ||
&mut parent, | ||
f as *const extern "C" fn(), | ||
&[], | ||
) | ||
.unwrap(); | ||
(stack, parent, child) | ||
}, | ||
|(stack, mut parent, child)| unsafe { | ||
Context::swap(&mut parent, &child); | ||
stack | ||
}, | ||
criterion::BatchSize::PerIteration, | ||
) | ||
}); | ||
} | ||
|
||
/// Time the call to sigprocmask as used in `Context::init()`. | ||
fn context_sigprocmask(c: &mut Criterion) { | ||
use nix::sys::signal; | ||
c.bench_function("context_sigprocmask", |b| { | ||
b.iter_batched( | ||
|| signal::SigSet::empty(), | ||
|mut sigset| { | ||
signal::sigprocmask(signal::SigmaskHow::SIG_SETMASK, None, Some(&mut sigset)) | ||
.unwrap() | ||
}, | ||
criterion::BatchSize::PerIteration, | ||
) | ||
}); | ||
} | ||
|
||
pub fn context_benches(c: &mut Criterion) { | ||
context_init(c); | ||
context_swap_return(c); | ||
context_sigprocmask(c); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
mod context; | ||
mod modules; | ||
mod par; | ||
mod seq; | ||
|
||
pub use context::context_benches; | ||
pub use par::par_benches; | ||
pub use seq::seq_benches; | ||
|
||
#[no_mangle] | ||
extern "C" fn lucet_benchmarks_ensure_linked() { | ||
lucet_runtime::lucet_internal_ensure_linked(); | ||
lucet_wasi::hostcalls::ensure_linked(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.