Slashdot Mirror


GNU GCC Vs Sun's Compiler on a SPARC

JigSaw writes "When doing research for his evaluation of Solaris 9 on his Ultra 5, Tony Bourke kept running into the same comment online over and over again: Sun's C compiler produces much faster code than GCC does. However, he couldn't find one set of benchmarks to back this up and so he did his own."

26 of 72 comments (clear)

  1. What CPU? by keesh · · Score: 3, Informative

    I wish this guy would tell us what CPU he's using. There's a hell of a lot of difference between the low-cache and high-cache CPUs (yes, these will work in a u5 as well as a u10). Looks like he's using a low-cache one, where there's not as much difference (and where the 64bit penalty isn't as noticeable).

    1. Re:What CPU? by Oinos · · Score: 3, Informative

      If you follow the "evaluation" link, it tells you. UltraSPARC IIi 333MHz 2MB Cache.

    2. Re:What CPU? by nelsonal · · Score: 4, Informative

      It's the same guy who bought a Sun system on ebay and has been writing columns on shiny new (to him anyway) system. The specs from the purchase article:

      The system I'm using is a second generation of the Ultra 5, released in late 1998. Here are the specs:

      System: Sun Ultra 5
      Processor: UltraSPARC IIi 333 MHz, 2MB cache
      Memory: 256 MB
      HD: Seagate Medalist 7200 RPM IDE Pro 9140 8.4 GB
      IDE Controller: Built-in UDMA2, 33 MB/s max
      CD-ROM: 32x IDE
      Video Controller: Sun PGX24 (ATI Mach64), 4 MB VRAM
      Network: Built-in 10/100 NIC (hme, "Happy Meal" interface)

      My knowledge of sun processors is a little lacking in the UltraSPARC II range, so I'll leave it to you to evaluate this one, My only exposure is the dead server CPU module for a paperweight. It and a foxtrot on the corkborad are my own version of the geek purity test.

      --
      Degaussing scares the bad magnetism out of the monitor and fills it with good karma.
    3. Re:What CPU? by carsont · · Score: 3, Informative

      The specs of the machine were in his first article.

      It's the 333 MHz processor with the 2 MB cache. (The same one that's in the U10 I'm using right now, by the way).

      --

      Ubi dubium, ibi libertas.
  2. ah 2.95.3, we hardly knew ye by dingbatdr · · Score: 4, Interesting

    To me this was the most interesting line of the article:

    Sun's compiler was the clear winner. Surprisingly, the older version of GNU's GCC beat 3.3.2 by a very slim margin.

    One of my favorite version numbers (2.95.3) is still getting good press. Cool.

    dtg

    --
    The truth is an offense, but not a sin.------R. N. Marley
  3. Why does this suprise ANYONE by MerlynEmrys67 · · Score: 3, Insightful
    I mean gcc's strength has never been fast code (all though it is no slouch) it has been cross platform. You can use GCC on everything from the biggest 64 bit procs down to the smallest embedded CPUs.

    Of course a vendors supplied compiler that doesn't have to even think about potential optimizations for another platform will outperform it. It is a testiment to the gcc folks that it is even close.

    --
    I have mod points and I am not afraid to use them
    1. Re:Why does this suprise ANYONE by ctr2sprt · · Score: 3, Informative
      I mean gcc's strength has never been fast code (all though it is no slouch) it has been cross platform.
      That's gcc's de facto status, but from the section of its info pages called "GCC and Portability:"
      The main goal of GCC was to make a good, fast compiler for machines in the class that the GNU system aims to run on: 32-bit machines that address 8-bit bytes and have several general registers. Elegance, theoretical power and simplicity are only secondary.
      It's interesting to note how gcc has turned out. I wonder what caused the change; if it were market forces, or changing developer priorities, or just coincidence.
    2. Re:Why does this suprise ANYONE by duffbeer703 · · Score: 3, Funny

      Those are Richard Stallman's goals, which don't really mirror anybody else's.

      And since the excerpt was from the info pages for GCC, you and stallman are likely the only humans to have ever read it.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
    3. Re:Why does this suprise ANYONE by Vladimir · · Score: 2, Interesting

      GCC is an excellent compiler. I was surprised why it didn't beat SUN's CC. In my experience, gcc frequently generates code which is at least as good or slightly better than vendor's compiler (at least for DEC, SPARC and Intel platforms). There are special cases, say OpenMP, SSE2, ect, when vendor's compiler does a better job (and gcc currently doesn't support openmp), but in most cases I can easily believe that gcc will be the best. In addition, knowing that a certain version of gcc compiled 8000 Debian packages for 10 different platforms and didn't failed (or if failed, a bug was submitted) is a good indicator that you can trust this compiler. Add to this that compiler gets better with each release and I think it will soon be what Linux is for UNIX - making the rest obsolete.

    4. Re:Why does this suprise ANYONE by AT · · Score: 3, Informative

      Actually, in early iterations, gcc killed most vendor's compilers, including Sun's. This was mostly because most vendors's compilers were absolutely terrible when gcc was first released. Since then, compiler technology has made huge advances and vendors have spent lots of effort improving them. At the same time, with the increasingly complex scheduling requirements of todays RISC processors, making a compiler fast takes a lot more work. Designing a portable instruction scheduler that performs good on very different processors is nearly impossible (though gcc does it surprisingly well).

    5. Re:Why does this suprise ANYONE by cant_get_a_good_nick · · Score: 4, Insightful

      Those may have been Stallman's original goals, but not necessarily of gcc anymore. Remember that the maintainers of gcc now aren't the original Stallman lead, FSF gcc folks, but of the splinter egcs group that forked gcc because they were extremely frustrated with the progress of gcc under the FSF. Once it became evident that egcs was making progress leaps and bounds past the FSF gcc, (to Stallman's credit) work on FSF gcc was dropped, and the egcs gcc became the official gcc.

      People think that "The Cathedral and the Bazaar" was made in comparison between commercial and non-commercial programming models. It actually was modeled on FSF gcc (the Cathedral) and Linux kernel (the Bazaar) development. Eventually, at least in gcc development, the Bazaar won.

    6. Re:Why does this suprise ANYONE by j-pimp · · Score: 4, Interesting

      Add to this that compiler gets better with each release and I think it will soon be what Linux is for UNIX - making the rest obsolete.

      I was talking to some Novell engineers at Linux World. They all love watcom. The watcom toolchain is being ported to linux. It already self bootstraps. Novell owns SuSE. I expect SuSE will be making use of watcom for linux in the future. All my projects are going to use Watcom from now on. I'm sick of the annoying voo-doo neccessary to make a cross compiler between unix and mingw/cygwin/djgpp using gcc. Watcom lets me cross compile out of the box. Granted the IDE needs some work, but wmake very powerful, though unique. All the basic unix userland you expect for a makefile (cp, rm, install) is a builtin command and calls to the tool chain (compiler, linker etc) are loaded as DLLs saving system calls, thus improving performance.

      GCC is very mature, popular and supported, but its not going to be the only kid on the block for long now that Watcom is open source.

      --
      --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
    7. Re:Why does this suprise ANYONE by Vladimir · · Score: 2, Insightful

      All I can say - competition is good. If Watcom is a decent compiler and will be able to compile kernel and Linux distro I am very glad. Most likely gcc team look critically what is good and what is bad and improve things were needed.

    8. Re:Why does this suprise ANYONE by turgid · · Score: 2, Insightful
      I was talking to some Novell engineers at Linux World. They all love watcom.

      Perhaps that's because Netware was written in Watcom C? Netware was very impressive in its day (late eighties, early nineties) having many features that we take for granted in Linux today. Watcom's C compiler used to be the best on the market for PeeCees, and could produce flat, 32-bit code for DOS extenders back when Microsoft C was still messing about in 16 bits. If you wanted to write an NLM for Netware, you used Watcom. It also targetted OS/2. Those were the days.

  4. Bad Statistics? by Josh+Booth · · Score: 4, Interesting

    See Tony Bourke's older article, which conluded that 64 bit binaries are slower than 32 bit binaries. This set of statistics he posted has totally obliterated his previous conclusion. He had only used GCC 3.3.2 and assumed that compiling for both 32 and 64 bits were optimized similarly. However, in most of the benchmarks he did with Sun's compiler, 64 bit programs came ahead of 32 bit ones. This means that GCC 3.3.2 is not as well optimized for his computer for 64 bits as for 32 bits, while the Sun compiler is. If he had just looked at his own data, he would have seen that.

  5. well, for $2995 vs. $0.00... by amarodeeps · · Score: 2, Insightful

    ...and a better performance not even all of the time, especially on a 32-bit platform, I choose GCC.

    However, I'd like to see a well-thought out criticism of this piece. It seems like someone always has a good counterpoint to any given set of benchmarks.

    1. Re:well, for $2995 vs. $0.00... by cant_get_a_good_nick · · Score: 3, Informative

      The Sun compiler has some optimizations, not turned on in this test, that gcc doesn't even offer. Scheduling optimization based on profiles from previous runs (rarely used) optimization and inlining across source files and across all program object files, ordering to help pagefault analysis, enable instruction prefetch, etc. If would be interesting to see if these have vast or just incremental improvements in the runtimes. I think Sun is adding auto-parallelization to future compilers. Most people don't use these optimizations since they imply some work and some testing to see whether or not they help a particular dataset. I know we don't, by the time we get something that we could test, we're already on a new codebase.

      That said, the fact that a generic compiler like gcc is within spitting distance of Forte or SunONE or whatever they call it this week is impressive.

    2. Re:well, for $2995 vs. $0.00... by 0x0d0a · · Score: 2, Informative

      Scheduling optimization based on profiles from previous runs (rarely used)

      gcc supports this.

  6. "clear" winner??? by ajagci · · Score: 5, Insightful

    So, the benchmarks show maybe a 10-15% difference in favor of Sun's compiler. Does that Sun's compiler a "clear winner"? I think not.

    First of all, it's far from clear that those differences are real. You can get much bigger differences from just changes in caching behavior, even with the same compiler.

    Then, there is the question of whether Sun's compiler is actually correct. A lot of commercial compilers intentionally skirt or break the letter of the ANSI standards once you start enabling optimizations. GNU C/C++ is usually more careful.

    Finally, you have to ask whether it matters. So, Sun's overpriced machines using their overpriced compilers run a bit faster than their overpriced machines using a free compiler. So what? If you want bang for the buck, or even just maximum bang, why in the world would you buy a Sun these days anyway?

    1. Re:"clear" winner??? by SewersOfRivendell · · Score: 3, Insightful

      Assuming he measured correctly, 15% is a lot. It's the minimum threshold for user-perceivable speed improvement, among other things. A lot of people would kill to have 15% faster compilers, kernels, databases, window managers, etc.

    2. Re:"clear" winner??? by DAldredge · · Score: 4, Informative

      The OpenSSL code has highly optimized assembly for those functions under x86. On other archs it is just C code that the compiler has to optimize.

      That may explain the speed difference that you are seeing.

  7. More technical brilliance from OSNews by duffbeer703 · · Score: 2, Insightful

    Next they'll be concluding what language is fastest by writing "Hello World!" in C (compiled in 64 & 32 bit), Logo, Perl and Prolog.

    I hope to be posting a full writeup on how much faster MS-DOS is compared to BSD using boot times as a benchmark.

    --
    Conformity is the jailer of freedom and enemy of growth. -JFK
  8. Sun's compilers are optimized for the big iron by lindsayt · · Score: 3, Interesting

    It's important to remember that Sun's compilers are optimized for Sun's big machines, so you don't really see the biggest advantages of the Sun compilers on single or even dual CPU machines. The Sun compilers really shine on the massively SMP machines such as the 10K, 12K, and 15K.

    Of course I don't have any links to benchmarks that prove this, so take it or leave it. But Sun specifically does not care about compiler optimization for their "toy" machines such as the Ultra 5, Ultra 10, Blade 100, etc. Basically, if your Sparc CPU isn't a straight II or straight III, Sun's not as concerned with you.

    --
    I did not design this game/I did not name the stakes/I just happen to like apples/And I am not afraid of snakes-AniD
  9. Re:[TROLL]Re:ah 2.95.3, we hardly knew ye by Brandybuck · · Score: 2, Funny

    Using DEPRECATED compilers is just as stupid as using DEPRECATED kernels(2.4, just to name one)

    Reason number 27 that I switched from Linux to FreeBSD. I got sick and tired of being treated like a lame poser just because I was still using last week's kernel.

    --
    Don't blame me, I didn't vote for either of them!
  10. the achille's heel? by MrLint · · Score: 3, Interesting

    Well slice it which ever way you want, this jives with what i hear about the virtual water cooler. gcc is all well and good on x86 (as where its been tweaked for ages) but not always the best elsewhere. MacOS X is where i hear this mostly. The more aggressively it get used outside of x86 land the more it will get tweaked.

    Move along nothing to see here.

  11. Of course, this puts forward the question... by 0x0d0a · · Score: 2, Insightful

    ...of who is using SPARC instead of x86 if they're worried about a 5% performance difference.