Skip to content

feat(perf): features for evaluation#678

Open
nokosaaan wants to merge 73 commits into
mainfrom
eva-feature
Open

feat(perf): features for evaluation#678
nokosaaan wants to merge 73 commits into
mainfrom
eva-feature

Conversation

@nokosaaan
Copy link
Copy Markdown
Contributor

@nokosaaan nokosaaan commented Apr 15, 2026

Description

Since period information is required during evaluation, I have provided a feature to enable evaluation outside of the application.
period-index-propagation is normally turned off, which is consistent with the behavior of the traditional awkernel. To enable it, simply add period-index-propagation to the default in the [features] section of kernel/Cargo.toml.

I have added perf as a feature for rv32 and rv64, but this is a temporary measure to pass tests on GitHub and is not intended to permanently add perf functionality to these targets.
The root cause of this issue has not yet been resolved and will be tracked in a separate issue.

I have updated pubsub.rs to allow cycle propagation without altering existing trait boundaries, APIs, or the test application. Please refer to the file attached to the PR test section for the execution results.

Related links

sample code

How was this PR tested?

no_feature_compile.log
no_feature_execute.log
feature_compile.log
feature_execute.log

Notes for reviewers

Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
@nokosaaan nokosaaan changed the title add: Features for evaluation add: features for evaluation Apr 17, 2026
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
@nokosaaan nokosaaan changed the title add: features for evaluation fix(perf): features for evaluation Apr 17, 2026
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>

This comment was marked as outdated.

…ta with features

Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
the logic for passing periodic information has been internalized and solve bootloader error changing const numbers by using Box

Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
nokosaaan added 6 commits May 20, 2026 11:12
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Comment thread awkernel_async_lib/src/dag.rs Outdated
Comment thread awkernel_async_lib/src/dag.rs Outdated
nokosaaan added 2 commits May 20, 2026 13:34
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
@kobayu858 kobayu858 changed the title fix(perf): features for evaluation feat(perf): features for evaluation May 20, 2026
Comment thread awkernel_async_lib/src/pubsub.rs Outdated
Comment thread awkernel_async_lib/src/time_interval.rs Outdated
Comment thread awkernel_async_lib/src/pubsub.rs
Comment thread awkernel_async_lib/src/pubsub.rs Outdated
Comment thread awkernel_async_lib/src/task.rs Outdated
}
}

fn update_time_and_state_for_dag(next_state: PerfState) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update_time_and_state_for_dag is an exact duplicate of update_time_and_state — not a single line differs. Despite the name implying DAG-specific behavior, both paths in start_interrupt and start_context_switch (branched via dag_info.is_some()) ultimately reach the same logic.

Please remove update_time_and_state_for_dag and consolidate both paths to call update_time_and_state directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove update_time_and_state_for_dag and merge it into update_time_and_state, do we no longer need to worry about the possibility that the code in start_interrupt, start_context_switch, and start_context_switch_main might be perceived as containing redundant if-else branches?
Or is the intent of this comment to eliminate all if-else branches and simply change the code to call update_time_and_state?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I’ve removed the if-else handling and made it so that update_time_and_state is called regardless of which task is received. Please let me know if this change was unintended.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's exactly what was intended. Since update_time_and_state_for_dag and update_time_and_state were identical, the if-else branches in start_interrupt, start_context_switch, and start_context_switch_main had no practical effect. Removing the branches and calling update_time_and_state directly is the correct fix. Thank you for making the change.

If you have a specific reason for wanting to keep update_time_and_state_for_dag, please let me know. In that case, please revert the change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. If calling the same function—whether in a regular task or a DAG task—doesn’t affect previous evaluation results, then I’m in favor of this change as well.

const MAX_NODES: usize = 20;
#[derive(Clone)]
struct PubSubTable {
timestamps: [[[u64; MAX_NODES]; MAX_PUBSUB]; MAX_LOGS],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments explaining the rationale behind MAX_LOGS, MAX_PUBSUB, and MAX_NODES, and whether there is any room for tuning them. As it stands, these constants result in a static allocation of roughly 3.75 MB (8192 × 3 × 20 × 8 bytes), which is fairly large and warrants some justification.

Copy link
Copy Markdown
Contributor Author

@nokosaaan nokosaaan May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAX_LOGS and MAX_NODES are adjustable constants, and I have left a comment to that effect. (Since MAX_LOGS is usually fine even if it is a bit smaller, I changed the default to 2048. The value of 2048 was chosen based on this branch.)

Copy link
Copy Markdown
Contributor Author

@nokosaaan nokosaaan May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of MAX_NODES was changed to 5.
This is because the test_dag test application, which runs the DAG, has 5 nodes. (If the user has configured a DAG with 10 nodes, this value can be changed to 10, or if the maximum number of nodes is updated frequently, it can be raised to a value that poses no issues.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining the rationale behind MAX_LOGS = 2048 and clarifying that this is a ring buffer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment.

Comment thread kernel/Cargo.toml
Comment on lines 78 to 106
@@ -92,12 +93,14 @@ x86 = [
"awkernel_drivers/uart_16550",
]
rv32 = [
"perf",
"no_std_unwinding",
"awkernel_lib/rv32",
"dep:ns16550a",
"awkernel_drivers/rv32",
]
rv64 = [
"perf",
"no_std_unwinding",
"awkernel_lib/rv64",
"dep:ns16550a",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the following:
① Update the PR description — State explicitly that perf was added as a temporary workaround because tests do not pass on rv32/rv64 without it, and that the root cause has not yet been investigated. Leaving the intent undocumented will confuse anyone who looks at this later.
② Add a TODO comment

rv32 = [
    # TODO: Remove once a way to pass tests without `perf` is found
    "perf",
    ...
]

③ Open a separate issue — It is recommended to track the investigation of why tests fail without perf on RISC-V in a dedicated issue. Left as-is, RISC-V builds will permanently carry the perf feature, which is likely unintended.

Comment thread awkernel_async_lib/src/task.rs Outdated
Comment thread awkernel_async_lib/src/task.rs Outdated
Comment thread awkernel_async_lib/src/task.rs Outdated
nokosaaan and others added 12 commits May 20, 2026 22:36
…ture

Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
…ontext_switch etc..

Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Comment thread awkernel_async_lib/src/task.rs Outdated
let recorder =
recorder_opt.get_or_insert_with(|| Box::new(core::array::from_fn(|_| BTreeMap::new())));

if recorder[log_index].get(&dag_id).copied().unwrap_or(0) == 0 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp 0 is used as a sentinel value meaning "not recorded", but this cannot be distinguished from a valid value if the system uptime happens to be near 0 ns at startup (unlikely in practice, but theoretically possible). Please either consider an alternative approach or add a comment acknowledging this limitation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

let item = $idx.recv().await;
match period_index {
Some(expected) => {
if expected != item.period_index {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mismatch handling here (adopt first, warn for rest) looks fine, but could we add a comment explaining the intent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment.

Comment thread kernel/src/main.rs Outdated

loop {
#[cfg(feature = "period-index-propagation")]
if last_print.elapsed().as_secs() >= 30 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a magic number. Please either introduce a named constant such as const PERF_PRINT_INTERVAL_SECS: u64 = 30; or make it configurable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

const MAX_NODES: usize = 20;
#[derive(Clone)]
struct PubSubTable {
timestamps: [[[u64; MAX_NODES]; MAX_PUBSUB]; MAX_LOGS],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining the rationale behind MAX_LOGS = 2048 and clarifying that this is a ring buffer.

nokosaaan added 6 commits May 22, 2026 11:55
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants