-
Notifications
You must be signed in to change notification settings - Fork 444
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
Expensive stream flushed #4922
Comments
I have no problems with switching out The only question is whether we can guarantee that we do end up flushing correctly? |
Since One of my thought for IndentCtl was to redo it by makeing it a streambuf and intercepting the overflow and inserting indentation there. That way it could do it automatically (and transparently) based on what was output, and could also wrap long lines properly. But that is a much bigger challenge |
Glad you suggested this :) As this is exactly my existing solution downstream.
This does not seem it would worth the complexity, right. |
And it turned out to be a bit tricky. The reason is that GC does not execute destructors for objects. As a result, the streams are never closed. And therefore what left in buffers is left there w/o explicit flush... |
We are having the following code in
lib/indent.h
:So, doing
out << IndentCtl::endl
essentially flushes the output stream. This is more or less fine forcout / cerr
, howeverIndentCtl
is used inUtils::Json
. As a result, serialization of json objects become terrible expensive due to constant flushes of output file stream, e.g.:I'm seeing possible ways of fixing this:
IndentCtl::endl
use\n
instead ofendl
endl
(though we'd need to expose current indent level then)Opinions? Tagging @ChrisDodd @grg @fruffy @vlstill
The text was updated successfully, but these errors were encountered: