stdio performance in tango, stdlib, and perl

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sat Mar 24 21:58:56 PDT 2007


Sean Kelly wrote:
> James Dennett wrote:
>>
>> It's not quite as simple as this.  One (possibly
>> killer) argument for building synchronization into
>> low-level libraries is to reduce the cost of
>> dealing with support issues from bemused users
>> who expected not to have to consider thread-safety
>> when sharing streams between threads.
> 
> ...since they obviously don't have to consider thread-safety when 
> sharing other objects between threads.  I'll admit that a global output 
> object might be seen as somehow magic to those who don't really 
> understand what 'cout' represents, for example, how much of a problem 
> would this really be?  The argument against building locking into C++ 
> containers seems fairly well-settled, so why does there seem to be so 
> much contention about output?  Is it that producing predictable behavior 
> is easier or that the cost of locking is less of an issue since IO is 
> expensive anyway?

Good question(s). Might be also that I/O interface is considerably 
simpler than container interface. The classic example of failure of 
method-level synchronization with containers is

if (!cont.empty()) cont.pop();

With I/O, most of the time, covert synchronization at the call level is 
all you need.


Andrei



More information about the Digitalmars-d mailing list