Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Performance of code compiled with the g++

Reply
Thread Tools

Performance of code compiled with the g++

 
 
Wojciech Waga
Guest
Posts: n/a
 
      08-24-2011
I was trying to test some performance gains of move semantics when I
came across a strange thing, namely:

For a code:
http://pastebin.com/3jqgyc8v

(There is a copy constructor to prevent gcc4.6 from using default move
constructor which speeds up things greatly, but is of no interest here.)

The speed of resulting binary differs vastly among versions of gcc. It
seems like gcc<4.5 gives pretty good binary, and gcc>=4.5 does not.
Intel compiler 12.0.0 gives results similar to gcc<4.5.

For those who prefer bare values:
The same code compiled with:
gcc4.4.6 runs 0.47s
gcc4.6.1 runs 1.73s

A full plot comparing 3 versions of gcc with std= c++98/c++0x is here:
http://www.wojek.net/ww/gcc_speed.png

Does anyone know what is wrong? Especially the difference between gcc4.6
with and without c++0x is interesting. Can be there any c++0x
optimisations in library routines for this code?

Best regards,
Wojciech Waga

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-24-2011
On 8/24/2011 3:38 AM, Wojciech Waga wrote:
> I was trying to test some performance gains of move semantics when I
> came across a strange thing, namely:
>
> For a code:
> http://pastebin.com/3jqgyc8v
>
> (There is a copy constructor to prevent gcc4.6 from using default move
> constructor which speeds up things greatly, but is of no interest here.)
>
> The speed of resulting binary differs vastly among versions of gcc. It
> seems like gcc<4.5 gives pretty good binary, and gcc>=4.5 does not.
> Intel compiler 12.0.0 gives results similar to gcc<4.5.
>
> For those who prefer bare values:
> The same code compiled with:
> gcc4.4.6 runs 0.47s
> gcc4.6.1 runs 1.73s
>
> A full plot comparing 3 versions of gcc with std= c++98/c++0x is here:
> http://www.wojek.net/ww/gcc_speed.png
>
> Does anyone know what is wrong?


You mean, besides the fact that GCC is community-based (meaning
everybody, but in fact *nobody*, is responsible for the functionality or
the performance)?

> Especially the difference between gcc4.6
> with and without c++0x is interesting. Can be there any c++0x
> optimisations in library routines for this code?


Nah... Optimisation? In the library routines?... Nah...

Could be that gcc C++0x is smart enough to see that your code has very
little side effect (no I/O to speak of) and it figures to let you down
easy and just puts some 'usleep' calls in there, just to keep you guessing?

Use a profiler and figure out where the differences are. Then look at
the machine code, if you're into it. But usually you should see all of
that in the source. It's not like your program is so complex that its
total source (including allocators and sorting) would be too hard to
comprehend.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
 
 
 
Edek
Guest
Posts: n/a
 
      08-24-2011
On 08/24/2011 09:38 AM, Wojciech Waga wrote:
> I was trying to test some performance gains of move semantics when I
> came across a strange thing, namely:
>
> For a code:
> http://pastebin.com/3jqgyc8v
>
> (There is a copy constructor to prevent gcc4.6 from using default move
> constructor which speeds up things greatly, but is of no interest here.)
>
> The speed of resulting binary differs vastly among versions of gcc. It
> seems like gcc<4.5 gives pretty good binary, and gcc>=4.5 does not.
> Intel compiler 12.0.0 gives results similar to gcc<4.5.
>
> For those who prefer bare values:
> The same code compiled with:
> gcc4.4.6 runs 0.47s
> gcc4.6.1 runs 1.73s
>
> A full plot comparing 3 versions of gcc with std= c++98/c++0x is here:
> http://www.wojek.net/ww/gcc_speed.png
>
> Does anyone know what is wrong? Especially the difference between gcc4.6
> with and without c++0x is interesting. Can be there any c++0x
> optimisations in library routines for this code?
>
> Best regards,
> Wojciech Waga
>


You might want to try here: http://www.velocityreviews.com/forums/(E-Mail Removed)

Edek
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-24-2011
On 8/24/2011 4:13 PM, Jorgen Grahn wrote:
> On Wed, 2011-08-24, Victor Bazarov wrote:
>> On 8/24/2011 3:38 AM, Wojciech Waga wrote:

> ...
>>> For those who prefer bare values:
>>> The same code compiled with:
>>> gcc4.4.6 runs 0.47s
>>> gcc4.6.1 runs 1.73s
>>>
>>> A full plot comparing 3 versions of gcc with std= c++98/c++0x is here:
>>> http://www.wojek.net/ww/gcc_speed.png
>>>
>>> Does anyone know what is wrong?

>>
>> You mean, besides the fact that GCC is community-based (meaning
>> everybody, but in fact *nobody*, is responsible for the functionality or
>> the performance)?

>
> Unlike proprietary software, where a single person is responsible ...?
>
> But seriously, do you have complaints about g++ performance, compared
> to something else? I haven't heard anyone complain for literally a
> decade, so I'm a bit curious.


*I* don't have any complaints - I haven't used that software for years
to have an up-to-date opinion. The OP has a complaint, apparently. Ask
him, maybe.

>
> /Jorgen
>


V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: gcj compiled executable performance Arne Vajh°j Java 7 04-04-2010 07:31 PM
Re: gcj compiled executable performance Roedy Green Java 1 03-28-2010 05:29 PM
If I create a page, then it's compiled upon first request, where cani find the compiled code?? lander ASP .Net 5 03-05-2008 04:34 PM
compiled DLL's and performance =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= ASP .Net 13 02-09-2005 09:10 AM
g++ compiled C++ code called from gcc compiled C code Klaus Schneider C++ 1 12-02-2004 01:44 PM



Advertisments