Skip to content

Add individual and total node duration measurements #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ThagonDuarte
Copy link
Contributor

Why? What?

Debugging #1822 was kind of annoying without proper timing measurements for node and cycle durations.
This PR expands on #710 and adds the cycle_timings field to each cycler database. This includes a total time measurement from the start of the first node of a cycler until the last node's cycle function terminates, which is the same as the cycler recording timestamp. This can be used under $cycler.cycle_timings.total.
Same as #710 did, this also adds node cycle durations for each individual node of a cycler. These can be accessed under $cycler.cycle_timings.$node

ToDo / Known Issues

If this is a WIP describe which problems are to be fixed.

Ideas for Next Iterations (Not This PR)

If there are some improvements that could be done in a next iteration, describe them here.

How to Test

  • Subscribe $cycler.cycle_timings in a twix text panel.

@oleflb
Copy link
Contributor

oleflb commented Apr 12, 2025

@knoellle what is your take on this? Should we give this a go now?

@knoellle
Copy link
Contributor

knoellle commented Apr 12, 2025

Yes!

7480wz-2569699538.jpg

Copy link
Contributor

@oleflb oleflb left a comment

Choose a reason for hiding this comment

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

I think

@@ -919,6 +926,8 @@ fn generate_execute_node_and_write_main_outputs(
)
.wrap_err(#cycle_error_message)?
};
let cycle_duration = cycle_start.elapsed().expect("time ran backwards");
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above

Comment on lines 43 to 74
cycler_structs
.cycle_times
.insert([
InsertionRule::InsertField {
name: "total".to_string(),
},
InsertionRule::AppendDataType {
data_type: Type::Verbatim(quote! { std::time::Duration }),
},
])
.map_err(|source| Error::Hierarchy {
node: "total_cycle_node_timings".to_string(),
cycler: cycler.name.clone(),
source,
})?;
for node in cycler.iter_nodes() {
cycler_structs
.cycle_times
.insert([
InsertionRule::InsertField {
name: node.name.to_case(Case::Snake),
},
InsertionRule::AppendDataType {
data_type: Type::Verbatim(quote! { std::time::Duration }),
},
])
.map_err(|source| Error::Hierarchy {
node: node.name.clone(),
cycler: cycler.name.clone(),
source,
})?;

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is duplicated (for total and then for all nodes). Can you use something like chain to have only one for loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pulled the field insertion out of the for loop and added another with iter::once().chain(). Is this what you had in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Request for Review
Development

Successfully merging this pull request may close these issues.

3 participants