stdio performance in tango, stdlib, and perl

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Thu Mar 22 00:05:58 PDT 2007


James Dennett wrote:
> Walter Bright wrote:
> 
> [snip]
> 
>> The conventional wisdom with C++ is that:
>>
>> 1) C++ code is inherently faster than in any other language
>> 2) iostream has a great design
>> 3) iostream is uber fast because it uses templates to inline everything
>>
>> Andrei's benchmark blows that out of the water. Even interpreted Perl
>> beats the pants off of C++ iostreams.
> 
> This kind of simplistic bashing of a language or library
> design based on testing of some unnamed implementation(s)
> of that library doesn't give D a good image.  There are
> other benchmarks that show C++ IOStreams beating C's
> stdio on performance.  Those are also meaningless out of
> context.

For the record, I used gcc 4.1.2 20060928 (prerelease) (Ubuntu 
4.1.1-13ubuntu5).

> There are real issues with some of the design of IOStreams.
> There are very real problems with many implementations of
> IOStreams.  There are also good implementations that
> perform pretty well, but overall IOStreams is not widely
> viewed in the C++ community as "having a great design",
> just as having a design that's OK, and a lot safer and
> more cleanly extensible than C's stdio.
> 
> Of course C++ code isn't inherently faster than any other
> language, and I've not come across anyone saying that it
> is.  And one of the main problems with IOStreams is that
> it makes excessive use of virtual functions in ways that
> inhibit inlining, particularly in typical implementations
> which drag in locale support even for programs that do
> not use it.  The C++ community recognizes these problems,
> and the C++ committee has addressed some of them (through
> exposition) in its Technical Report on C++ performance.
> 
> I'm at a loss to understand why you would write what you
> did.  It seems to be a straw man, but maybe there was
> something else to it -- frustration that people assume
> that D must be slower than C++?

I don't know why he wrote that, but my perception is that iostreams have 
always been "on the verge of an efficient implementation" for eight 
years now. What I've seen repeatedly year after year whenever I sat down 
to run a test was performance that make iostream practically unusable 
for any serious coding. I'd be faster at moving molasses upstream on a 
cold day. I am amazed how iostreams managed to maintain this clout for 
so long. If they were a guy, I'd love to know his trick. :o)


Andrei



More information about the Digitalmars-d mailing list