From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,be98569334bf359 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: C++ threads vs. Ada tasks - surprised References: From: Stephen Leake Date: Mon, 17 Aug 2009 03:12:29 -0400 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (windows-nt) Cancel-Lock: sha1:Al44uhIQw0s13FdoYw+Hja8TR90= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 7d9c74a8902dae197caa722246 Xref: g2news2.google.com comp.lang.ada:7835 Date: 2009-08-17T03:12:29-04:00 List-Id: Maciej Sobczak 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