Compiling Ruby w/ Profile Guided Optimization

G

Greg Buchholz

Since gcc-4.1 now has the option to perform profile guided
optimization, I thought I'd try compiling a version of Ruby with this
feature turned on. For the (somewhat contrived/synthetic) scenario
below, it looks like compiling with profile guided optimization turned
on, along with -O3, results in about a 9% speed increase vs. -O3 alone.
YMMV. I compiled a version of Ruby-1.8.4 using the following config
options...

configure CFLAGS="-O3 -fprofile-generate"
LDFLAGS=-fprofile-generate

....Then I ran the short version of the n-body program from the Great
Computer Language Shootout with n=1000...


http://shootout.alioth.debian.org/debian/benchmark.php?test=nbody&lang=ruby&id=0

....this generated the profile information needed for the next stage. I
then compiled a Ruby with...

configure CFLAGS="-O3 -fprofile-use"

....Running the resulting interpreter runs the exact same n-body program
about 8-10% faster than an compiling with just -O3.

FWIW,

Greg Buchholz
 
P

Phil Tomson

Since gcc-4.1 now has the option to perform profile guided
optimization, I thought I'd try compiling a version of Ruby with this
feature turned on. For the (somewhat contrived/synthetic) scenario
below, it looks like compiling with profile guided optimization turned
on, along with -O3, results in about a 9% speed increase vs. -O3 alone.
YMMV. I compiled a version of Ruby-1.8.4 using the following config
options...

configure CFLAGS="-O3 -fprofile-generate"
LDFLAGS=-fprofile-generate

...Then I ran the short version of the n-body program from the Great
Computer Language Shootout with n=1000...


http://shootout.alioth.debian.org/debian/benchmark.php?test=nbody&lang=ruby&id=0

...this generated the profile information needed for the next stage. I
then compiled a Ruby with...

configure CFLAGS="-O3 -fprofile-use"

...Running the resulting interpreter runs the exact same n-body program
about 8-10% faster than an compiling with just -O3.

Cool! What exactly is 'profile guided optimization'?

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top