This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Something terribly wrong with gcc-3.0.4 Linux


On Thu, Mar 28, 2002 at 10:15:02AM -0500, Neal D. Becker wrote:
> >>>>> "Paolo" == Paolo Carlini <pcarlini@unitus.it> writes:
> 
>     Paolo> Neal D. Becker wrote:
>     Paolo> std::ios::sync_with_stdio(false);
>     >> 
>     Paolo> before any other output operations?
>     >> 
>     >> No, I haven't tried that yet, but I sure don't expect that I need to
>     >> in order to not have cout << "hello world" not call write() for every
>     >> character.
>     >> 
>     Paolo> You don't expect this, on which basis? For sure, the standard offers
>     Paolo> no guarantees. Quite to the contrary,
>     Paolo> std::ios::sync_with_stdio(false); is the correct approach if you want
>     Paolo> to trade sync with stdio for speed: on this, see, f.i., Josuttis,
>     Paolo> pp. 682.
> 
> 
> I understand that the default for cout is to sync with stdio.  I
> (naively) imagined that this meant some extra calls to the C library,
> not a trip through the kernel for every character.  This is really a
> surprising amount of extra overhead.  Is it possible to implement
> streams to avoid this?

If libstdc++-v3 switches (optionally) back to libio, this overhead would
go away.
But I believe for std::cout << "hello " << "world";
even without libio we should be able to write(1, "hello ", 6); write(1, "world", 5);
instead of 11 writes. Ben, have you looked into it already?

	Jakub


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