Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions examples/rust/cycle-benchmark-orchstrator-feo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
load("@cargo//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

rust_library(
name = "libcycle_benchmark_rust",
srcs = [
"src/activities.rs",
"src/config.rs",
"src/lib.rs",
],
crate_name = "cycle_benchmark",
visibility = ["//visibility:public"],
deps = [
"//feo:libfeo_recording_rust",
"//feo-com:libfeo_com_rust",
"//feo-log:libfeo_log_rust",
"//feo-logger:libfeo_logger_rust",
"//feo-time:libfeo_time_rust",
"//feo-tracing:libfeo_tracing_rust",
"@cargo//:postcard",
"@cargo//:serde",
"@cargo//:serde_json",
],
)

rust_binary(
name = "cycle_bench",
srcs = [
"src/bin/cycle_bench.rs",
],
visibility = ["//visibility:public"],
deps = [
":libcycle_benchmark_rust",
"//feo:libfeo_recording_rust",
"//feo-log:libfeo_log_rust",
"//feo-logger:libfeo_logger_rust",
"//feo-time:libfeo_time_rust",
"//feo-tracing:libfeo_tracing_rust",
],
)
30 changes: 30 additions & 0 deletions examples/rust/cycle-benchmark-orchstrator-feo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "cycle-benchmark"
version = "0.1.0"
edition = "2021"

[[bin]]
path = "src/bin/cycle_bench.rs"
name = "cycle_bench"
required-features = []

[dependencies]
feo = { workspace = true }
feo-log = { workspace = true }
feo-logger = { workspace = true }
feo-time = { workspace = true }
feo-tracing = { workspace = true }
tracing = { workspace = true }
postcard = { workspace = true, features = ["experimental-derive"] }
serde = { workspace = true }
serde_json = { workspace = true }

async_runtime = { workspace = true }
orchestration = { workspace = true }
logging_tracing = { workspace = true }
foundation = { workspace = true }

[build-dependencies]

[features]
default = []
23 changes: 23 additions & 0 deletions examples/rust/cycle-benchmark-orchstrator-feo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Cycle time benchmark

A simple configurable benchmarking application to measure the FEO cycle time in various signalling and
single- or multi-agent setups.

## Running

Adapt the config file `config/cycle_bench.json` to reflect your desired setup. Then run one or more
instances of the application in different terminals:

```sh
cargo run --release --bin cycle_bench -- <AGENT_ID> [TARGET_CYCLE_TIME]
```

The first command line parameter specifies the agent ID of the process to be started. The second parameter defines
the the target FEO cycle time for the scheduler. It is only relevant for the primary agent and defaults to 5ms if
not given.

If the specified agent ID is equal to the primary ID defined in the config file, the above command will start the
primary agent. If it is equal to one of the secondary agent IDs (i.e. an agent ID in the config that is not
equal to the primary ID), it will start a secondary agent. Finally, if the agent ID matches one of the
recorder IDs from the config file, a recorder will be started.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"cycle_time_ms": 0,
"primary_agent": 1000,
"agent_assignments": {
"1000":
[10,
[ 1, 11, 21,
101,
31, 41, 51,
102,
61, 71, 81,
103]]
},
"activity_graph":
[ [[1], true],
[[11], true],
[[21], true],
[[101], false],
[[31], true],
[[41], true],
[[51], true],
[[102], false],
[[61], true],
[[71], true],
[[81], true],
[[103], false]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"cycle_time_ms": 0,
"primary_agent": 1000,
"agent_assignments": {
"1000":
[3,
[ 1, 2, 3, 4, 5,
11, 12, 13, 14, 15,
21, 22, 23, 24, 25,
101,
31, 32, 33, 34, 35,
41, 42, 43, 44, 45,
51, 52, 53, 54, 55,
102,
61, 62, 63, 64, 65,
71, 72, 73, 74, 75,
81, 82, 83, 84, 85,
103]]
},
"activity_graph":
[ [[1, 2, 3, 4, 5], true],
[[11, 12, 13, 14, 15], true],
[[21, 22, 23, 24, 25], true],
[[101], false],
[[31, 32, 33, 34, 35], true],
[[41, 42, 43, 44, 45], true],
[[51, 52, 53, 54, 55], true],
[[102], false],
[[61, 62, 63, 64, 65], true],
[[71, 72, 73, 74, 75], true],
[[81, 82, 83, 84, 85], true],
[[103], false]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"cycle_time_ms": 0,
"primary_agent": 1000,
"agent_assignments": {
"1000":
[10,
[ 1, 11, 21,
101,
31, 41, 51,
102,
61, 71, 81,
103]]
},
"activity_graph":
[ [[1], true],
[[11], true],
[[21], true],
[[101], false],
[[31], true],
[[41], true],
[[51], true],
[[102], false],
[[61], true],
[[71], true],
[[81], true],
[[103], false]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"cycle_time_ms": 0,
"primary_agent": 1000,
"agent_assignments": {
"1000":
[10,
[ 1, 21,
101,
31, 51,
102,
61, 81,
103]],
"1001":
[10,
[ 11, 41, 71]]
},
"activity_graph":
[ [[1], true],
[[11], true],
[[21], true],
[[101], false],
[[31], true],
[[41], true],
[[51], true],
[[102], false],
[[61], true],
[[71], true],
[[81], true],
[[103], false]
]
}
70 changes: 70 additions & 0 deletions examples/rust/cycle-benchmark-orchstrator-feo/src/activities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2025 Accenture.
//
// SPDX-License-Identifier: Apache-2.0

use crate::runtime_adapters::{get_activity_name, ActivityAdapterTrait};
use feo::activity::{Activity, ActivityId};
use feo_tracing::{instrument, tracing, Level};
use orchestration::prelude::ActionResult;
use std::future::Future;
use std::sync::{Arc, Mutex};
use tracing::event;

/// This is a dummy activity that does nothing.
#[derive(Debug)]
pub struct DummyActivity {
/// ID of the activity
activity_id: ActivityId,
activity_name: &'static str,
}

impl DummyActivity {
pub fn build(activity_id: &ActivityId) -> Self {
Self {
activity_id: *activity_id,
activity_name: get_activity_name(activity_id.into()),
}
}
}

impl Activity for DummyActivity {
fn id(&self) -> ActivityId {
self.activity_id
}

#[instrument(name = "Activity startup")]
fn startup(&mut self) {}

#[instrument(name = "Activity step")]
fn step(&mut self) {
event!(Level::INFO, id = self.activity_name);
}

#[instrument(name = "Activity shutdown")]
fn shutdown(&mut self) {}
}

impl ActivityAdapterTrait for DummyActivity {
type T = DummyActivity;

fn step_runtime(instance: Arc<Mutex<Self::T>>) -> impl Future<Output = ActionResult> + Send {
async move {
instance.lock().unwrap().step();
Ok(())
}
}

fn start(&mut self) -> ActionResult {
self.startup();
Ok(())
}

fn stop(&mut self) -> ActionResult {
self.shutdown();
Ok(())
}

fn get_named_id(&self) -> &'static str {
self.activity_name
}
}
Loading
Loading