Skip to content

Commit

Permalink
Merge pull request #484 from elfenpiff/iox2-483-add-copy-to-benchmark
Browse files Browse the repository at this point in the history
[#483] Add --send-copy flag to pub/sub benchmark
  • Loading branch information
elfenpiff authored Oct 25, 2024
2 parents 5f6a0dc + 0859def commit 72ff56e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
37 changes: 27 additions & 10 deletions benchmarks/publish-subscribe/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::mem::MaybeUninit;

use clap::Parser;
use iceoryx2::prelude::*;
use iceoryx2_bb_log::set_log_level;
Expand Down Expand Up @@ -60,11 +62,17 @@ fn perform_benchmark<T: Service>(args: &Args) -> Result<(), Box<dyn std::error::

barrier.wait();

let mut sample = unsafe {
sender_a2b
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
let mut sample = if args.send_copy {
let mut sample = sender_a2b.loan_slice_uninit(args.payload_size).unwrap();
sample.payload_mut().fill(MaybeUninit::new(0));
unsafe { sample.assume_init() }
} else {
unsafe {
sender_a2b
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
}
};

for _ in 0..args.iterations {
Expand Down Expand Up @@ -93,12 +101,19 @@ fn perform_benchmark<T: Service>(args: &Args) -> Result<(), Box<dyn std::error::
barrier.wait();

for _ in 0..args.iterations {
let sample = unsafe {
sender_b2a
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
let sample = if args.send_copy {
let mut sample = sender_b2a.loan_slice_uninit(args.payload_size).unwrap();
sample.payload_mut().fill(MaybeUninit::new(0));
unsafe { sample.assume_init() }
} else {
unsafe {
sender_b2a
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
}
};

while receiver_a2b.receive().unwrap().is_none() {}

sample.send().unwrap();
Expand Down Expand Up @@ -152,6 +167,8 @@ struct Args {
/// The size in bytes of the payload that shall be used
#[clap(short, long, default_value_t = 8192)]
payload_size: usize,
#[clap(long)]
send_copy: bool,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
5 changes: 3 additions & 2 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add Event-Multiplexer `WaitSet` [#390](https://github.com/eclipse-iceoryx/iceoryx2/issues/390)
* Add `PeriodicTimer` into POSIX building blocks [#425](https://github.com/eclipse-iceoryx/iceoryx2/issues/425)
* Developer permissions for resources [#460](https://github.com/eclipse-iceoryx/iceoryx2/issues/460)
* Add `--send-copy` flag to Benchmark to consider mem operations [#483](https://github.com/eclipse-iceoryx/iceoryx2/issues/483)

### Bugfixes

Expand Down Expand Up @@ -58,7 +59,7 @@

### API Breaking Changes

1. Renamed `NodeEvent` into `WaitEvent`
1. Removed `NodeEvent`. `Node::wait` returns now `Result<(), NodeWaitFailure>`

```rust
// old
Expand All @@ -67,7 +68,7 @@
}

// new
while node.wait(CYCLE_TIME) != WaitEvent::TerminationRequest {
while node.wait(CYCLE_TIME).is_ok() {
// ...
}
```

0 comments on commit 72ff56e

Please sign in to comment.