Skip to content

Commit

Permalink
[build] Enhancement: Makefile can now run rust benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbonde committed Feb 6, 2025
1 parent 8636d46 commit 9114a93
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 23 deletions.
6 changes: 3 additions & 3 deletions benchmarks/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*====================================================================================================================*/

/**
* @brief Microbenchmark for demi_wait_any().
* @brief Benchmark for demi_wait_any().
*/
static void microbench_wait_any(const unsigned NUM_ITERS, const unsigned NUM_QTS)
static void wait_any_bench(const unsigned NUM_ITERS, const unsigned NUM_QTS)
{
demi_qtoken_t *qts = NULL;

Expand Down Expand Up @@ -81,7 +81,7 @@ int main(int argc, char *const argv[])
};
assert(demi_init(&args) == 0);

microbench_wait_any(100000, 1048576);
wait_any_bench(100000, 1048576);

return (EXIT_SUCCESS);
}
4 changes: 2 additions & 2 deletions dpdk_bindings/inlined.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ char *rte_pktmbuf_prepend_(struct rte_mbuf *m, uint16_t len)
struct rte_mbuf *rte_mbuf_from_indirect_(struct rte_mbuf *mi)
{
return rte_mbuf_from_indirect(mi);
}
}

void rte_pktmbuf_detach_(struct rte_mbuf *m)
{
rte_pktmbuf_detach(m);
}
}
3 changes: 3 additions & 0 deletions linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ clean-examples-rust:
# Benchmarks
#=======================================================================================================================

bench:
$(CARGO) bench $(CARGO_FEATURES) $(CARGO_FLAGS) -- --nocapture

all-benchmarks-c: all-libs
$(MAKE) -C benchmarks all

Expand Down
8 changes: 4 additions & 4 deletions src/rust/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,14 @@ mod tests {
}

#[bench]
fn benchmark_insert_io_coroutine(b: &mut Bencher) {
fn insert_io_coroutine_bench(b: &mut Bencher) {
let mut runtime: SharedDemiRuntime = SharedDemiRuntime::default();

b.iter(|| runtime.insert_nonpolling_coroutine("dummy coroutine", Box::pin(dummy_coroutine(10).fuse())));
}

#[bench]
fn benchmark_insert_background_coroutine(b: &mut Bencher) {
fn insert_background_coroutine_bench(b: &mut Bencher) {
let mut runtime: SharedDemiRuntime = SharedDemiRuntime::default();

b.iter(|| {
Expand All @@ -605,7 +605,7 @@ mod tests {
}

#[bench]
fn benchmark_run_any_fine(b: &mut Bencher) {
fn wait_any_nonpolling_coroutine_bench(b: &mut Bencher) {
const NUM_TASKS: usize = 1024;
let mut qts: [QToken; NUM_TASKS] = [QToken::from(0); NUM_TASKS];
let mut runtime: SharedDemiRuntime = SharedDemiRuntime::default();
Expand All @@ -621,7 +621,7 @@ mod tests {
}

#[bench]
fn benchmark_run_any_background_long(b: &mut Bencher) {
fn wait_any_io_polling_coroutine_bench(b: &mut Bencher) {
const NUM_TASKS: usize = 1024;
let mut qts: [QToken; NUM_TASKS] = [QToken::from(0); NUM_TASKS];
let mut runtime: SharedDemiRuntime = SharedDemiRuntime::default();
Expand Down
2 changes: 1 addition & 1 deletion src/rust/runtime/queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mod tests {
}

#[bench]
fn bench_alloc_free(b: &mut Bencher) {
fn alloc_free_bench(b: &mut Bencher) {
let mut ioqueue_table: IoQueueTable = IoQueueTable::default();

b.iter(|| {
Expand Down
4 changes: 2 additions & 2 deletions src/rust/runtime/scheduler/page/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod tests {
}

#[bench]
fn bench_notify(b: &mut Bencher) {
fn notify_bench(b: &mut Bencher) {
let pg: WakerPage = WakerPage::default();
let x: usize = rand::thread_rng().gen_range(0..WAKER_BIT_LENGTH);

Expand All @@ -139,7 +139,7 @@ mod tests {
}

#[bench]
fn bench_take_notified(b: &mut Bencher) {
fn take_notified_bench(b: &mut Bencher) {
let pg: WakerPage = WakerPage::default();

// Initialize 8 random bits.
Expand Down
4 changes: 2 additions & 2 deletions src/rust/runtime/scheduler/page/waker_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod tests {
}

#[bench]
fn bench_wake(b: &mut Bencher) {
fn wake_bench(b: &mut Bencher) {
let p: WakerPageRef = WakerPageRef::default();
let ix: usize = rand::thread_rng().gen_range(0..WAKER_BIT_LENGTH);

Expand All @@ -259,7 +259,7 @@ mod tests {
}

#[bench]
fn bench_wake_by_ref(b: &mut Bencher) {
fn wake_by_ref_bench(b: &mut Bencher) {
let p: WakerPageRef = WakerPageRef::default();
let ix: usize = rand::thread_rng().gen_range(0..WAKER_BIT_LENGTH);

Expand Down
6 changes: 3 additions & 3 deletions src/rust/runtime/scheduler/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ mod tests {
}

#[bench]
fn benchmark_insert(b: &mut Bencher) {
fn insert_bench(b: &mut Bencher) {
let mut scheduler: Scheduler = Scheduler::default();
let group_id: TaskId = scheduler.create_group();

Expand All @@ -382,7 +382,7 @@ mod tests {
}

#[bench]
fn benchmark_poll_one_task(b: &mut Bencher) {
fn poll_one_task_bench(b: &mut Bencher) {
let mut scheduler: Scheduler = Scheduler::default();
let group_id: TaskId = scheduler.create_group();

Expand All @@ -403,7 +403,7 @@ mod tests {
}

#[bench]
fn benchmark_poll_many_tasks_until_done(b: &mut Bencher) {
fn poll_many_tasks_until_done_bench(b: &mut Bencher) {
let mut scheduler: Scheduler = Scheduler::default();
let group_id: TaskId = scheduler.create_group();

Expand Down
12 changes: 6 additions & 6 deletions src/rust/runtime/scheduler/waker64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ mod tests {
use ::test::{black_box, Bencher};

#[bench]
fn bench_fetch_and(b: &mut Bencher) {
fn fetch_and_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);
let w64: Waker64 = Waker64::new(0);

Expand All @@ -111,7 +111,7 @@ mod tests {
}

#[bench]
fn bench_fetch_or(b: &mut Bencher) {
fn fetch_or_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);
let w64: Waker64 = Waker64::new(0);

Expand All @@ -122,7 +122,7 @@ mod tests {
}

#[bench]
fn bench_fetch_add(b: &mut Bencher) {
fn fetch_add_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);
let w64: Waker64 = Waker64::new(0);

Expand All @@ -133,7 +133,7 @@ mod tests {
}

#[bench]
fn bench_fetch_sub(b: &mut Bencher) {
fn fetch_sub_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);

b.iter(|| {
Expand All @@ -144,7 +144,7 @@ mod tests {
}

#[bench]
fn bench_load(b: &mut Bencher) {
fn load_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);
let w64: Waker64 = Waker64::new(x);

Expand All @@ -155,7 +155,7 @@ mod tests {
}

#[bench]
fn bench_swap(b: &mut Bencher) {
fn swap_bench(b: &mut Bencher) {
let x: u64 = rand::thread_rng().gen_range(0..64);
let w64: Waker64 = Waker64::new(0);

Expand Down
7 changes: 7 additions & 0 deletions windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ clean-examples-rust:
set BINDIR=$(BINDIR)
$(MAKE) /C /F examples/rust/windows.mk clean

#=======================================================================================================================
# Benchmarks
#=======================================================================================================================

bench:
$(CARGO) bench $(CARGO_FEATURES) $(CARGO_FLAGS) -- --nocapture

#=======================================================================================================================
# Code formatting
#=======================================================================================================================
Expand Down

0 comments on commit 9114a93

Please sign in to comment.