This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: libstdc++/3269: Inefficient stream output, one 'write' call per character


Thanks for the work around. I will start to use sync_with_stdio for our
code, but I think that many other developers are unaware of the change and
the severity of its effects.

I still don't see why it is necessary to issue one syscall per *character*
when data is passed in atomic chunks. Why not sync/flush between each atomic
chunk boundary? The implementation should be able to fullfill the
"unbuffered" requirement without having to fragment existing strings/buffers
that are passed. Even if multiple threads are writing simultaneously to a
stream, interleaving the flows per character is a bit too fine-grained. The
change (made since the 2001-05-07 snapshot) causes abysmal performance in
many situations.

Regards, Anders

----- Original Message -----
From: <bkoz@gcc.gnu.org>
To: <anders.furuhed@pantor.com>; <bkoz@gcc.gnu.org>; <gcc-bugs@gcc.gnu.org>;
<gcc-prs@gcc.gnu.org>; <nobody@gcc.gnu.org>
Sent: Tuesday, June 26, 2001 12:02 PM
Subject: Re: libstdc++/3269: Inefficient stream output, one 'write' call per
character


> Synopsis: Inefficient stream output, one 'write' call per character
>
> Responsible-Changed-From-To: unassigned->bkoz
> Responsible-Changed-By: bkoz
> Responsible-Changed-When: Tue Jun 26 03:02:16 2001
> Responsible-Changed-Why:
>     Mine.
> State-Changed-From-To: open->feedback
> State-Changed-By: bkoz
> State-Changed-When: Tue Jun 26 03:02:16 2001
> State-Changed-Why:
>     #include <iostream>
>
>     main (int argc, char** argv)
>     {
>       std::ios::sync_with_stdio(false);
>       std::cerr << "Hello world" << std::endl;
>     }
>
>     $ strace a.out 2>&1 | grep write
>     write(2, "Hello world", 11Hello world)             = 11
>     write(2, "\n", 1
>
>     The standard streams are unbuffered by default. If you unsync them
from the "C" streams with std::ios::sync_with_stdio(false) then you'll have
much better luck.
>
>     -benjamin
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3269&database=gcc
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]