The view from the Engine Room

pageicon Wednesday Jun 15, 2005

Most common recent benchmarking mistake

Most frequently asked performance question of late: Why is this trivial piece of code slower on Solaris than on Linux with both OSes running on the same Opteron box?

Often this is because the default compilation mode using /usr/sfw/bin/gcc (or Studio, for that matter) on Solaris is always a portable binary - and 64 bit Solaris x86 isn't seen as a different architecture, since all the 32 bit programs still work just fine. So

gcc -o foo foo.c 

produces a 32 bit binary on Solaris amd64, and a 64 bit binary when compiled on a 64 bit Linux. No wonder there's a performance difference! To get 64 bit compilation using gcc, simply use the -m64 flag:

gcc -o foo foo.c -m64

When in doubt, specify what you want - you'll more likely get what you need.

Comments:

Uhm, I think the default with almost any distribution's gcc build is to produce a 32 bit binary on Linux as well. So, while a useful tip, I don't think that actually explains any speed differential between Linux and Solaris.

Posted by 216.58.44.227 on June 16, 2005 at 07:23 AM PDT #


Well, let's just try and see..

[tdv@jcg-amd64-02:] -< /tmp >
#>gcc -o test test.c
test.c: In function `main':
test.c:1: warning: return type of `main' is not `int'
[tdv@jcg-amd64-02:] -< /tmp >
#>file test
test: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[tdv@jcg-amd64-02:] -< /tmp >
#>uname -a
Linux jcg-amd64-02 2.4.19-SMP #1 SMP Thu Jul 17 21:37:10 UTC 2003 x86_64 unknown

-------
Now on Solaris on amd64

[tdv@jcg-amd64-05:] -< /tmp >
#>gcc -o test test.c
test.c: In function `main':
test.c:1: warning: return type of `main' is not `int'
[tdv@jcg-amd64-05:] -< /tmp >
#>file test
test:           ELF 32-bit LSB executable 80386 Version 1, dynamically linked, not stripped, no debugging information available
[tdv@jcg-amd64-05:] -< /tmp >
#>uname -a
SunOS jcg-amd64-05 5.10 gate:2005-01-10 i86pc i386 i86pc
#>isainfo
amd64 i386

Thanks,
  Dmitri
Java2D Team

Posted by Dmitri Trembovetski on June 16, 2005 at 08:28 AM PDT #

Dmitri that must have been a slashdot poster hard at work :-)

Posted by 208.237.173.72 on June 16, 2005 at 12:30 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« October 2009
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Feeds

Search this blog

Links

Weblog menu

Today's referrers

Today's Page Hits: 132