-
Notifications
You must be signed in to change notification settings - Fork 41
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
Synchronize console writes #227
Conversation
Codecov Report
@@ Coverage Diff @@
## ign-common4 #227 +/- ##
===============================================
+ Coverage 77.07% 77.10% +0.03%
===============================================
Files 75 75
Lines 10679 10694 +15
===============================================
+ Hits 8231 8246 +15
Misses 2448 2448
Continue to review full report at Codecov.
|
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.
I'd be interested in knowing how this affects performance.
Also, this could be targeted at ign-common3
, right?
src/Console.cc
Outdated
Console::log << outstr; | ||
Console::log.flush(); | ||
{ | ||
std::lock_guard<std::mutex> lk(syncMutex); |
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.
Did you consider having separate mutexes for logging to disk and logging to the console? This way different loggers could write to disk and to console at the same time. It may be a small optimization, but when logging a lot it could make a difference?
I agree. We don't have any metric for console performance right now, so it's a bit handwavy. |
Signed-off-by: Michael Carroll <michael@openrobotics.org>
https://gist.github.com/KjellKod/4d88035f9af513eed69e Signed-off-by: Michael Carroll <michael@openrobotics.org>
I copied this latency test from a spdlog test I found: https://gist.github.com/KjellKod/4d88035f9af513eed69e All times are in microseconds: Without the mutex:
With the mutex:
|
I found more data races with TSAN and opened a PR suggesting chagnes: #237 |
* More data race fixes Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
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.
LGTM! Since I wrote part of this PR, another pair of eyes might be good.
The ABI check is not happy because of the new |
I'm not sure if that's true. The |
So...it looks like |
Looking at the ABI report again, it looks like the only issue is the new mutex. Can we do the static map trick to avoid adding the member variable? |
Signed-off-by: Nate Koenig <nate@openrobotics.org>
Static map used in b08f53a |
Thanks @nkoenig for adding the map. My concern with using a global variable is that it violates the GSG guideline about objects of static duration that have non-trivial destructors. I would vote for making the map a function-local static variable that gets allocated on the heap and never gets deleted. I know this would cause errors when running under a memory profiler, but I think it's worth it to avoid the potential bugs that can be caused by having the map be a global variable. |
Sounds good. I'll step aside, and let you or someone else take the wheel. |
Signed-off-by: Michael Carroll <michael@openrobotics.org>
@azeey ready for another look, switched to function local static map pointer. |
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.
LGTM! Checked with TSAN. Just a few nits
src/Console.cc
Outdated
@@ -14,6 +14,7 @@ | |||
* limitations under the License. | |||
* | |||
*/ | |||
#include <map> |
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: Should this be unordered_map
since that's what we're using in BufferLock
?
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.
Are we planning to backport this to citadel? |
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Probably need to increase the timeout on the test. I think that's why windows CI is failing. |
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Done, it looks like we are only failing in the plugin specialization test, which is known flaky. |
Add PBR material class Signed-off-by: Michael Carroll <michael@openrobotics.org>
This pull request has been mentioned on Gazebo Community. There might be relevant details there: https://community.gazebosim.org/t/new-ignition-releases-2022-01-24-citadel-edifice-fortress/1241/1 |
Provide an internal mechanism for console writes. This will prevent messages from being interleaved. Signed-off-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Nate Koenig <nate@openrobotics.org>
Provide an internal mechanism for console writes. This will prevent messages from being interleaved. Signed-off-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Nate Koenig <nate@openrobotics.org>
Provide an internal mechanism for console writes. This will prevent messages from being interleaved. Signed-off-by: Michael Carroll <michael@openrobotics.org> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Nate Koenig <nate@openrobotics.org>
Signed-off-by: Michael Carroll michael@openrobotics.org
🎉 New feature
Summary
Provide an internal mechanism for console writes. This will prevent messages from being interleaved.
Test it
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge