[ # ] Double Your Compiler Speed

/* Posted March 20th, 2008 at 8:59am */
/* Filed under Linux, Microsoft, Programming */

gcc compiler speedup
(credit: Phoronix)

Nowadays dual core processors are all the rage, with quad core processors just now entering the market. Why not make use of all the extra computer power? It was just a few years ago that only powerful computing clusters in universities and the workplace had dual CPU machines (not to be confused with dual core where you have two CPUs on the same die rather than two CPUs on separate dies) that you could use this special gcc trick to speed up your compilation time. Today everyone can readily enjoy the benefits of dual CPU computing and one of those, if you develop on Unix, is decreasing the time you need to wait while your code compiles. An oft overlooked but highly scalable feature of the free gcc compiler is the “-j” option, which allows you to fork the files being compiled among any number of processors. If you’ve compiled on Unix, you’re probably doing this (or some variation):
make
To take advantage of your extra core, use this:
make -j2
where 2 is the number of processors you want to fork the compile process to. Yes, it’s that simple! What this does is load balance the “make” job as files get compiled to different CPUs. This means if you only compile one file, this option will do nothing for you as the first (and only file) gets sent off to a CPU and that’s it. Since there’s no other file to compile, you’d have to wait as if you did not use the -j option. Also I lied, since this is not precise load balancing, your speedup will vary. If you’re compiling two files but one file takes much longer than the other, you’re going to have to wait for that big file to finish compiling even as the second one finishes. Another drawback is when you encounter compile errors, the compilation does not stop instantly. Rather it waits for any currently compiling files to finish before it returns control back to you.

As you can see from the top graph, the dual core Xeon 5150 core compile times are sped up in a scalable manner from 12 seconds to 8 seconds as the -j option gets used. Similarly, the quad core Xeon E5320 performs in a similarly, getting a speed up from 11 seconds with one core to 8 seconds with two cores.

Well, what if I use Windows, you say? Tough luck Windows users. The Microsoft compiler supplied with Visual Studio is a decent compiler, but it doesn’t have the scalability of gcc. Check out these benchmarks below on dual and quad core CPUs. See any difference? No? That’s because there isn’t any, the Microsoft compiler doesn’t get any faster with more cores.

ms compiler no speedup
(credit: xtreview)

  • Digg
  • del.icio.us
  • Propeller
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Mixx
  • NewsVine
  • Blogsvine
  • Facebook
  • Google
  • TwitThis


Related Posts

Leave a Reply


*


* (not published, used to display your gravatar)



(* required)

Anything Geeky Goes!

Highlights

Featured Wii

Featured iPhone

Featured PSP/PS3

Featured A/V

Related Links

Archives

Products Highlight


Featured Sites

Categories

Subscribe

Recent Posts

Commentors

Other Links