From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: C++ threads vs. Ada tasks - surprised
Date: Mon, 17 Aug 2009 03:12:29 -0400
Date: 2009-08-17T03:12:29-04:00 [thread overview]
Message-ID: <ueiraykv6.fsf@stephe-leake.org> (raw)
In-Reply-To: f02a0d10-acaa-47d3-ade8-2e7bd4030bd8@d4g2000yqa.googlegroups.com
Maciej Sobczak <see.my.homepage@gmail.com> writes:
> An important point that was discussed there was the potential gain
> from having tasking built-in the language. I have argued that there is
> none *functional* gain (there is an obvious gain in readability,
> though), or rather that all compiler tricks can be performed with
> standard API as well.
This makes sense, except that with a higher-level tasking model, there
is more room for optimization of simple cases.
> To be frank: I have expected to see the C++ version being a hell lot
> of faster, as the Ada tasking model is conceptually much more complex
> and therefore I have expected tons of overhead there.
I would not have expected much speed difference; Ada tasks map quite
nicely to Posix threads.
> My expectations were wrong, as the Ada version proved to be ~2x
> faster on my machine (with GNAT 4.4.0 and g++ 4.4.0, taken from the
> same package, both versions compiled with -O2).
Interesting!
Getting this benchmark on the shootout page would be nice :).
> After this exercise I have no choice (frankly) than to admit that
> built-in threading support is better *also* in terms of performance.
> Damned benchmarks... ;-)
You could explain this by saying the Ada implementation took advantage
of what it knows about tasking, while the C++ implementation did _not_
take advantage of any knowledge about the Posix tasking API.
So the challenge is to add that knowledge to g++, and see if it
actually helps.
I guess the issue is "what compiler/run-time tricks were used to make
the Ada code faster than the simple calls to Posix"?
You could try using -gnatD to see what lower-level constructs GNAT
used.
And there's some sort of "trace" facility in Linux, that reports calls
to "system" routines; that might be useful (I've never used it).
--
-- Stephe
next prev parent reply other threads:[~2009-08-17 7:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-16 21:34 C++ threads vs. Ada tasks - surprised Maciej Sobczak
2009-08-17 7:12 ` Stephen Leake [this message]
2009-08-17 8:14 ` Maciej Sobczak
2009-08-17 19:44 ` vlc
2009-08-17 8:04 ` Frederik Sausmikat
2009-08-17 8:17 ` Maciej Sobczak
2009-08-17 8:28 ` Tomek Wałkuski
2009-08-17 9:39 ` Frederik Sausmikat
2009-08-17 9:44 ` Ludovic Brenta
2009-08-17 11:12 ` John McCabe
2009-08-17 15:20 ` John B. Matthews
2009-08-18 20:36 ` Ira Baxter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox