Skip to content
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

Bugprone Tick time monitoring #861

Open
Petzep opened this issue Aug 26, 2024 · 2 comments
Open

Bugprone Tick time monitoring #861

Petzep opened this issue Aug 26, 2024 · 2 comments

Comments

@Petzep
Copy link

Petzep commented Aug 26, 2024

Describe the bug
The time measurement of a tick is bug-prone.

auto t1 = steady_clock::now();
new_status = tick();
auto t2 = steady_clock::now();

This way of measuring time can be reordered by the compiler and will result in a time difference of 0.
A good explanation of this issue can be found here:
Enforcing statement order in C++

The article also discusses a fix.

And I've also seen examples where they fix it with an atomic fence (which cost's no extra cylces)
https://stackoverflow.com/questions/22278963/how-to-prevent-timestamp-from-being-reorder-out

@facontidavide
Copy link
Collaborator

you are welcome to submit a PR to address this.

@Aglargil
Copy link
Contributor

Aglargil commented Sep 6, 2024

#863
This might help?

Aglargil pushed a commit to Aglargil/BehaviorTree.CPP that referenced this issue Sep 6, 2024
… for performance monitoring. (BehaviorTree#861)

Update src/tree_node.cpp

Co-authored-by: Davide Faconti <[email protected]>
Aglargil pushed a commit to Aglargil/BehaviorTree.CPP that referenced this issue Sep 6, 2024
… for performance monitoring. (BehaviorTree#861)

Update src/tree_node.cpp

Co-authored-by: Davide Faconti <[email protected]>
facontidavide added a commit that referenced this issue Sep 21, 2024
… for performance monitoring. (#861) (#863)

Update src/tree_node.cpp

Co-authored-by: wangzheng <[email protected]>
Co-authored-by: Davide Faconti <[email protected]>
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

No branches or pull requests

3 participants