-
Notifications
You must be signed in to change notification settings - Fork 356
LinearBatteryPlugin stability improvement #2725
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
LinearBatteryPlugin stability improvement #2725
Conversation
Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
test/integration/battery_plugin.cc
Outdated
| // start the battery draining when the server starts again. | ||
| gz::transport::Node node; | ||
| auto pub = node.Advertise<msgs::StringMsg>("/battery/discharge"); | ||
| auto discharge_pub = node.Advertise<msgs::StringMsg>("/battery/discharge"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do you mind to use camelCase here?
test/integration/battery_plugin.cc
Outdated
|
|
||
| // Send a message on one of the <stop_power_draining_topic> topics, which | ||
| // will stop the battery draining when the server starts again. | ||
| auto stop_pub = node.Advertise<msgs::StringMsg>("/battery/stop_discharge"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do you mind to use camelCase here?
caguero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! Agreed on your 1) and 3) points. About 2), not sure about the impact of that optimization because there are other aspects to be considered as well (are members used together, etc.). We normally don't consider that type of optimization when programming. In any case, it's absolutely fine your proposal of rearranging the member variables as I think is harmless, just saying that without seeing numbers I'm not 100% convinced about its impact :)
In any case, this topic is super interesting and we usually don't pay much attention to it. If you're interested in these kind of optimizations we could try to explore them in more depth trying to consider alignments with cache lines, etc. and measure the impact of the changes.
It's not about alignment with cache lines (for this we have alignas and it's more about false-sharing) It's more about memory throughput. For a big structures or if we have just few instances it's maybe has lower impact. Still optimization is a very big topic, I done it here maybe almost automatically, and TBH, I more interested in more convenient and productive usage of simulator, but my resources as a contributor are very limited |
🦟 Bug fix
Fixes #
Summary
This PR contain 3 different changes
startDrainingshould be atomic due to we are changing it in callback which can be called from other thread (valgrind --tool=drd or helgrind)It's quite simple to add some keys to compiler just by defining some env.variables before a clean build execution
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-bymessages.