Forum: Ruby on Rails FreeBSD Performance Tip

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8c43ed7f065406bf171c0f3eb32cf615?d=identicon&s=25 Zed Shaw (Guest)
on 2006-03-20 04:56
(Received via mailing list)
A small note to all the FreeBSD folks about Ruby performance.

While trying to tune Mongrel to run faster on FreeBSD I was stumped as
to
why it was so horribly slow compared to Linux.  Linux on the same
machine
was getting about 800 req/sec, and FreeBSD was maybe pushing 23 req/sec.
Pathetic.

I managed to tweak the thread model in Mongrel and get FreeBSD up to
about
210 req/sec but still that wasn't nearly good enough.

Then I found the secret.  FreeBSD has two versions of Ruby in the ports
directory:  lang/ruby18 and lang/ruby18-nopthreads.

Using the nopthreads version of Ruby immediately gave me 740 req/sec
without
any changes to Mongrel.  I have no idea what Ruby is doing in the
pthreads
version (or why in the hell a thread library based on select *also* uses
pthreads), but this simple change completely solved all my performance
problems.

So, word to the wise:  pthreads do not give you performance.

Enjoy!

Zed A. Shaw
http://www.zedshaw.com/
4dd3a635239b88c8005b21c233074379?d=identicon&s=25 Tony Perrie (Guest)
on 2006-03-20 05:00
(Received via mailing list)
I can't seem to find this page anywhere.  Has it moved?  As it is now,
the
url seems to redirect back to the main page.

Tony
http://involution.com
B8d11b4c89cfc6e34d6c9fb121c9acac?d=identicon&s=25 Claus Guttesen (Guest)
on 2006-03-20 14:27
(Received via mailing list)
> Using the nopthreads version of Ruby immediately gave me 740 req/sec without
> any changes to Mongrel.  I have no idea what Ruby is doing in the pthreads
> version (or why in the hell a thread library based on select *also* uses
> pthreads), but this simple change completely solved all my performance
> problems.

Thank you for sharing this. As an avid FreeBSD user I will check this
in relation to ruby. What FreeBSD version are you talking about?

regards
Claus
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2006-03-20 17:12
(Received via mailing list)
On 3/19/06, Tony Perrie <tony@involution.com> wrote:
>
> I can't seem to find this page anywhere.  Has it moved?  As it is now, the
> url seems to redirect back to the main page.


Since 1.0, all api docs have moved to http://api.rubyonrails.org/.

/Nick
Eea7ad39737b0dbf3de38874e0a6c7d8?d=identicon&s=25 Justin Forder (Guest)
on 2006-03-22 03:43
(Received via mailing list)
Zed Shaw wrote:
> Then I found the secret.  FreeBSD has two versions of Ruby in the ports
> directory:  lang/ruby18 and lang/ruby18-nopthreads.
>
> Using the nopthreads version of Ruby immediately gave me 740 req/sec without
> any changes to Mongrel.  I have no idea what Ruby is doing in the pthreads
> version (or why in the hell a thread library based on select *also* uses
> pthreads), but this simple change completely solved all my performance
> problems.
>
> So, word to the wise:  pthreads do not give you performance.

Coincidentally, on the same day as your post Eric Hodel published
details of the software setup at Robot Co-op:

   http://blog.segment7.net/articles/2006/03/20/robot...

They run on FreeBSD, and he says: "We use the lang/ruby18-nopthreads
port of Ruby because we experienced an incredible load increase with the
default pthread version."

Info on the hardware is here:

   http://blog.segment7.net/articles/2006/03/15/robot...

   Justin
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-03-23 20:54
(Received via mailing list)
On Mar 20, 2006, at 5:27 AM, Claus Guttesen wrote:

>> Then I found the secret.  FreeBSD has two versions of Ruby in the
>> performance
>> problems.
>
> Thank you for sharing this. As an avid FreeBSD user I will check this
> in relation to ruby. What FreeBSD version are you talking about?

All of them.

If you use Ruby with pthread-requiring C/C++ libraries, ruby-
nopthreads may do bad things.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-03-23 21:18
Interesting. Did you have to deinstall and rebuild any Ruby-related
ports when you did this, or did everything Just Work?

Zed Shaw wrote:
> A small note to all the FreeBSD folks about Ruby performance.
>
> While trying to tune Mongrel to run faster on FreeBSD I was stumped as
> to
> why it was so horribly slow compared to Linux.  Linux on the same
> machine
> was getting about 800 req/sec, and FreeBSD was maybe pushing 23 req/sec.
> Pathetic.
>
> I managed to tweak the thread model in Mongrel and get FreeBSD up to
> about
> 210 req/sec but still that wasn't nearly good enough.
>
> Then I found the secret.  FreeBSD has two versions of Ruby in the ports
> directory:  lang/ruby18 and lang/ruby18-nopthreads.
34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-03-23 22:07
Answered it satisfactorily for myself. Held my nose, stopped apache, ran
make, deinstalled the default build of ruby and installed the nopthreads
version. The performace boost seems to be dramatic. I was considering
migrating from a VPS to a dedicated server and I don't think I'll have
to for a while. Thanks. Get this on the wiki if it's not there already.

Steve Koppelman wrote:
> Interesting. Did you have to deinstall and rebuild any Ruby-related
> ports when you did this, or did everything Just Work?
>
> Zed Shaw wrote:
>> A small note to all the FreeBSD folks about Ruby performance.
>>
>> While trying to tune Mongrel to run faster on FreeBSD I was stumped as
>> to
>> why it was so horribly slow compared to Linux.  Linux on the same
>> machine
>> was getting about 800 req/sec, and FreeBSD was maybe pushing 23 req/sec.
>> Pathetic....
>> Then I found the secret.  FreeBSD has two versions of Ruby in the ports
>> directory:  lang/ruby18 and lang/ruby18-nopthreads.
This topic is locked and can not be replied to.