3

I am using a package that is compiled using gcc -O3 -g.

Since some function calls to that code are the slowest part of my program I am wondering if the -g could be the culprit? Or should it not matter in terms of runtime?

Frank
  • 64,140
  • 93
  • 237
  • 324
  • 3
    Well, did you try taking out the `-g` flag, and re-measuring the performance? – Oliver Charlesworth Apr 13 '11 at 22:40
  • @Oli: If the answers had been "no there is no way that can matter since -O3 is turned on" then I wouldn't have bothered to test. But given that the answers are slightly vague I think I'll do the test. – Frank Apr 13 '11 at 22:48
  • Okay, indeed didn't make a difference, even though those functions were called 100 million times. – Frank Apr 13 '11 at 23:03

3 Answers3

2

Since -O3 implies aggressive inlining, and -g implies avoiding inlining so that the debugger can have function addresses, those options are somewhat at odds. Nevertheless in general -O3 wins, and aside from a somewhat larger binary -- and the minor speed effects that might come from paging or nonlocality -- it should not make much of a difference.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
2

-g will make your code bigger (added space for debug symbols) and will disable some optimizations like inlining, but probably not appreciably slower.

Marc Abramowitz
  • 3,447
  • 3
  • 24
  • 30
0

If your real question is "Why is it slow?" there's an easy way to find out.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135