any tricks to speed up ruby?

R

Roger Pack

Wondering if anybody had suggestions for how to speed up 1.8.6 on an old
mac os x ppc. Thoughts?
Thanks.
-Roger
 
B

Bill Kelly

From: "Roger Pack said:
Wondering if anybody had suggestions for how to speed up 1.8.6 on an old
mac os x ppc. Thoughts?

Not sure if this applies to OS X or not, but there have been some posts recently
showing speed gains when one rebuilds 1.8.x configured with --disable-pthread
(if I recall correctly.)


Regards,

Bill
 
R

Roger Pack

Not sure if this applies to OS X or not, but there have been some posts
recently
showing speed gains when one rebuilds 1.8.x configured with
--disable-pthread

Thanks! Now if I can just figure out how to check if mine is built with
pthreads enabled...
-Roger
 
J

James Britt

Roger said:
Wondering if anybody had suggestions for how to speed up 1.8.6 on an old
mac os x ppc. Thoughts?

Before this goes too far, the answer "Use C" would be considered:

A) Helpful
B) Trolling
C) Flame-bait
D) Laughable
E) None of the above




--
James Britt

"I have the uncomfortable feeling that others are making a religion
out of it, as if the conceptual problems of programming could be
solved by a single trick, by a simple form of coding discipline!"
- Edsger Dijkstra
 
T

tomas pospisek

Thanks! Now if I can just figure out how to check if mine is built with
pthreads enabled...

tpo@petertosh:~$ ldd `which ruby`
[...]
libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7e8e000)

This one has'em.
*t
 
R

Robert Klemme

Not sure if this applies to OS X or not, but there have been some posts recently
showing speed gains when one rebuilds 1.8.x configured with --disable-pthread
(if I recall correctly.)

I also believe to remember that optimization options made a significant
difference.

Roger, you are sure that you have exhausted all optimizations of Ruby
code, are you?

Kind regards

robert
 
R

Roger Pack

Unfortunately it's for a rails app so I am unequivocally (except for
maybe using evented mongrel) stuck with the default app performance.
Thanks for the tips on the optimizations!
 
R

Roger Pack

Before this goes too far, the answer "Use C" would be considered:
A) Helpful
B) Trolling
C) Flame-bait
D) Laughable
E) None of the above

I like it!
"Ruby is so slow! I can't believe no one out there has ways to optimize
1.8.6! Terrible!"
Bait thrown.
lol
Thanks.
-Roger
 
J

John Carter

S

s.ross

If you have a Rails app that is taking a long time in Ruby code, then
you obviously have a compute-intensive action. Perhaps you could find
the most expensive part of that action and rewrite it in C using ruby-
inline (http://www.zenspider.com/ZSS/Products/RubyInline/). If you
haven't looked into this, and if you really need to write some tight C
code, then you will kiss the feet of Ryan Davis for making it all so
easy.
 
R

Ryan Davis

If you have a Rails app that is taking a long time in Ruby code,
then you obviously have a compute-intensive action. Perhaps you
could find the most expensive part of that action and rewrite it in
C using ruby-inline (http://www.zenspider.com/ZSS/Products/
RubyInline/). If you haven't looked into this, and if you really
need to write some tight C code, then you will kiss the feet of Ryan
Davis for making it all so easy.

...at least take me out for a drink first...

eww
 
D

Daniel DeLorme

tomas said:
Thanks! Now if I can just figure out how to check if mine is built with
pthreads enabled...

tpo@petertosh:~$ ldd `which ruby`
[...]
libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7e8e000)

This one has'em.

That is not necessarily true. It's possible to have ruby compiled with
--disable-pthread and yet have libpthread linked in. At least it works
that way on FreeBSD. [1]

Daniel

[1]http://lists.freebsd.org/pipermail/freebsd-ports/2006-March/030691.html
 
C

Charles Oliver Nutter

James said:
Before this goes too far, the answer "Use C" would be considered:

A) Helpful
B) Trolling
C) Flame-bait
D) Laughable
E) None of the above

Heh, same question for "Use JRuby"...

- Charlie
 
M

M. Edward (Ed) Borasky

James said:
Before this goes too far, the answer "Use C" would be considered:

A) Helpful
B) Trolling
C) Flame-bait
D) Laughable
E) None of the above

Well ... my answer was, "if it's a notebook, I'll give you $50 for it." :)

Seriously, though, the answer "Buy a faster Mac" would be considered:

A) Cheating
B) Lazy
C) A wiser use of resources than trying to tweak Ruby 1.8.6
D) Premature optimization
E) All of the above

So ... I assume you tried

$ export CFLAGS='march=ppc -O3'
$ ./configure
$ make
 
J

John Carter

It's an old trick, I believe the kde folks do it (I may be wrong)

Instead of creating lots and lots of .o's and linking them...

Pull all the .c files into one stonking great .c file and compile
that with...

`-fwhole-program'
Assume that the current compilation unit represents whole program
being compiled. All public functions and variables with the
exception of `main' and those merged by attribute
`externally_visible' become static functions and in a affect gets
more aggressively optimized by interprocedural optimizers. While
this option is equivalent to proper use of `static' keyword for
programs consisting of single file, in combination with option
`--combine' this flag can be used to compile most of smaller scale
C programs since the functions and variables become local for the
whole combined compilation unit, not for the single source file
itself.


Takes forever and needs a huge amount of RAM, but it gives the
optimizer more freedom.

I wonder how hard it would be to tweak the ruby Makefile into doing that?


John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
M

M. Edward (Ed) Borasky

John said:
It's an old trick, I believe the kde folks do it (I may be wrong)

Instead of creating lots and lots of .o's and linking them...

Pull all the .c files into one stonking great .c file and compile
that with...

`-fwhole-program'
Assume that the current compilation unit represents whole program
being compiled. All public functions and variables with the
exception of `main' and those merged by attribute
`externally_visible' become static functions and in a affect gets
more aggressively optimized by interprocedural optimizers. While
this option is equivalent to proper use of `static' keyword for
programs consisting of single file, in combination with option
`--combine' this flag can be used to compile most of smaller scale
C programs since the functions and variables become local for the
whole combined compilation unit, not for the single source file
itself.


Takes forever and needs a huge amount of RAM, but it gives the
optimizer more freedom.

I wonder how hard it would be to tweak the ruby Makefile into doing that?


John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand

It's an interesting thought. However, I wasn't able to get gcc 4.2.2 to
do some simpler things, like profile-based optimization, on the Ruby
source, so I wouldn't expect something that complex to work out of the
box. There are a lot of great things in gcc, but not many of them are as
well tested as, say, the standard modular C library or program, and, of
course, the Linux kernel.

As far as I know, "-O3 -march=<your processor type>" is about the best
you can get out of gcc without a *lot* of work. And there are a lot more
things you can do at the Ruby source level that have a bigger payoff
than that does.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top