any tricks to speed up ruby?

Discussion in 'Ruby' started by Roger Pack, Jan 14, 2008.

  1. Roger Pack

    Roger Pack Guest

    Wondering if anybody had suggestions for how to speed up 1.8.6 on an old
    mac os x ppc. Thoughts?
    Thanks.
    -Roger
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Jan 14, 2008
    #1
    1. Advertising

  2. Roger Pack

    Bill Kelly Guest

    From: "Roger Pack" <>
    >
    > 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
    Bill Kelly, Jan 14, 2008
    #2
    1. Advertising

  3. Roger Pack

    Roger Pack Guest


    > 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
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Jan 14, 2008
    #3
  4. Roger Pack

    James Britt Guest

    Roger Pack wrote:
    > 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
    James Britt, Jan 14, 2008
    #4
  5. Roger Pack

    Victor Reyes Guest

    [Note: parts of this message were removed to make it a legal post.]

    F

    On Jan 14, 2008 4:17 PM, James Britt <> wrote:

    > Roger Pack wrote:
    > > 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
    >
    >
    Victor Reyes, Jan 14, 2008
    #5
  6. On Tue, 15 Jan 2008, Roger Pack wrote:

    >> 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...


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

    This one has'em.
    *t

    --
    -----------------------------------------------------------------------
    Tomas Pospisek
    http://sourcepole.com - Linux & Open Source Solutions
    ------------------------------------------------------------------------
    tomas pospisek, Jan 14, 2008
    #6
  7. On 14.01.2008 19:55, Bill Kelly wrote:
    > From: "Roger Pack" <>
    >> 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.)


    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
    Robert Klemme, Jan 14, 2008
    #7
  8. Roger Pack

    Roger Pack Guest

    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!
    > Roger, you are sure that you have exhausted all optimizations of Ruby
    > code, are you?
    >
    > Kind regards
    >
    > robert


    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Jan 14, 2008
    #8
  9. Roger Pack

    Roger Pack Guest

    > 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
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Jan 14, 2008
    #9
  10. Roger Pack

    John Carter Guest

    On Tue, 15 Jan 2008, James Britt wrote:

    > Roger Pack wrote:
    >> 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


    Helpfully trolling with laughable flamebait?

    http://weblog.textdrive.com/article/175/rails-optimizing-resource-usage

    http://rubygarden.org/ruby/page/show/RubyOptimization



    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand
    John Carter, Jan 15, 2008
    #10
  11. Roger Pack

    s.ross Guest

    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.

    On Jan 14, 2008, at 2:05 PM, Roger Pack wrote:

    > 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!
    >> Roger, you are sure that you have exhausted all optimizations of Ruby
    >> code, are you?
    >>
    >> Kind regards
    >>
    >> robert

    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    s.ross, Jan 15, 2008
    #11
  12. Roger Pack

    Ryan Davis Guest

    On Jan 14, 2008, at 20:23 , s.ross wrote:

    > 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
    Ryan Davis, Jan 15, 2008
    #12
  13. tomas pospisek wrote:
    >> 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
    Daniel DeLorme, Jan 15, 2008
    #13
  14. Roger Pack

    s.ross Guest

    Ground on which you walk, then, Ryan.


    eeewwww ;/

    On Jan 14, 2008, at 8:30 PM, Ryan Davis wrote:

    >
    > On Jan 14, 2008, at 20:23 , s.ross wrote:
    >
    >> 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
    >
    >
    s.ross, Jan 15, 2008
    #14
  15. > > On Jan 14, 2008, at 20:23 , s.ross wrote:
    > >> some tight C code, then you will kiss the feet of Ryan Davis for
    > >> making it all so easy.


    > On Jan 14, 2008, at 8:30 PM, Ryan Davis wrote:
    > > ...at least take me out for a drink first...
    > > eww


    On Jan 15, 2008 5:26 PM, s.ross <> wrote:
    > Ground on which you walk, then, Ryan.
    > eeewwww ;/


    What... and waste a good drink?!?!

    Mikel
    Mikel Lindsaar, Jan 15, 2008
    #15
  16. Roger Pack

    ara.t.howard Guest

    On Jan 14, 2008, at 11:05 AM, Roger Pack wrote:

    >
    > Wondering if anybody had suggestions for how to speed up 1.8.6 on
    > an old
    > mac os x ppc. Thoughts?
    > Thanks.
    > -Roger
    > --
    > Posted via http://www.ruby-forum.com/.
    >



    use narray whenever possible.

    a @ http://codeforpeople.com/
    --
    we can deny everything, except that we have the possibility of being
    better. simply reflect on that.
    h.h. the 14th dalai lama
    ara.t.howard, Jan 15, 2008
    #16
  17. James Britt wrote:
    > Roger Pack wrote:
    >> 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


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

    - Charlie
    Charles Oliver Nutter, Jan 16, 2008
    #17
  18. James Britt wrote:
    > Roger Pack wrote:
    >> 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
    >
    >
    >
    >


    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
    M. Edward (Ed) Borasky, Jan 16, 2008
    #18
  19. Roger Pack

    John Carter Guest

    Re: any tricks to speed up ruby? -fwhole-program?

    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 :
    New Zealand
    John Carter, Jan 16, 2008
    #19
  20. Re: any tricks to speed up ruby? -fwhole-program?

    John Carter wrote:
    > 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 :
    > 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.
    M. Edward (Ed) Borasky, Jan 16, 2008
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siemel Naran
    Replies:
    1
    Views:
    272
    Phlip
    Dec 8, 2004
  2. Hooyoo
    Replies:
    9
    Views:
    495
    Hooyoo
    Aug 28, 2007
  3. Shailesh Humbad

    ASP Speed Tricks

    Shailesh Humbad, Jul 7, 2003, in forum: ASP General
    Replies:
    17
    Views:
    301
    Shailesh Humbad
    Jul 9, 2003
  4. Shailesh Humbad

    ASP Speed Tricks updated

    Shailesh Humbad, Jul 22, 2003, in forum: ASP General
    Replies:
    16
    Views:
    239
    Shailesh Humbad
    Aug 4, 2003
  5. Weng Lei-QCH1840
    Replies:
    1
    Views:
    175
    Thomas
    Aug 15, 2003
Loading...

Share This Page