Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@cbodley after a second thought, i feel that we are covering potential bugs. if we fail to print a logging message because of the badbit set by previous logging message printed using this TLS stream instance, it is a sign that we have a programming error when printing logging messages. because we should not print a
(std::streambuf*)nullptr
, should we?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.
As the person who noticed this bug, and having thought about this line of reasoning, I'd prefer that we reset the stream. The fact that in libstdc++ environments "nothing happens" other than recoverable stream failure after sending the nullptr, means that attention may not be drawn to a future case where we send bad data. If a case does slip in, the stream reset makes it easier to find, as well as remediating the damage.
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.
Performance cost of the reset would be a strong reason not to do it, though. I suspect that's not an issue though?
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.
@mattbenjamin badbit denotes irrecoverable error. so all following logging messages won't be printed. so i guess it'd be relatively easy to track back to the offending log line which was not printed?
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.
@mattbenjamin @tchaikov
Without clear() on stream:
[ RUN ] Log.Speed_gather
[ OK ] Log.Speed_gather (1222 ms)
[ RUN ] Log.Speed_nogather
[ OK ] Log.Speed_nogather (46 ms)
With clear() on stream:
[ RUN ] Log.Speed_gather
[ OK ] Log.Speed_gather (1247 ms)
[ RUN ] Log.Speed_nogather
[ OK ] Log.Speed_nogather (45 ms)
Before TLS optimizations:
[ RUN ] Log.Speed_gather
[ OK ] Log.Speed_gather (1636 ms)
[ RUN ] Log.Speed_nogather
[ OK ] Log.Speed_nogather (49 ms)
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.
@aclamk thank you for profiling this change. i don't feel strong either way then.