# FreeBSD Performance Tip

**URL:** <https://www.ruby-forum.com/t/freebsd-performance-tip/84071>\
**Category:** Rails\
**Created:** [March 20, 2006, 4:56am UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071 "2006-03-20T04:56:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 20, 2006, 4:56am UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/1 "2006-03-20T04:56:15Z")

</div>

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

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 20, 2006, 5:00am UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/2 "2006-03-20T05:00:43Z")

</div>

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](http://involution.com)

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 20, 2006, 2:27pm UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/3 "2006-03-20T14:27:48Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 22, 2006, 3:43am UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/4 "2006-03-22T03:43:39Z")

</div>

Zed S. 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 H. published  
details of the software setup at Robot Co-op:

[http://blog.segment7.net/articles/2006/03/20/robot-co-op-software](http://blog.segment7.net/articles/2006/03/20/robot-co-op-software)

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-co-op-hardware](http://blog.segment7.net/articles/2006/03/15/robot-co-op-hardware)

Justin

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 20, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/5 "2006-03-20T17:12:39Z")

</div>

On 3/19/06, Tony P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://api.rubyonrails.org/).

/Nick

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 23, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/6 "2006-03-23T21:18:25Z")

</div>

Interesting. Did you have to deinstall and rebuild any Ruby-related  
ports when you did this, or did everything Just Work?

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

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 23, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/7 "2006-03-23T22:07:26Z")

</div>

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 K. wrote:

> Interesting. Did you have to deinstall and rebuild any Ruby-related  
> ports when you did this, or did everything Just Work?
> 
> Zed S. 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.

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [March 23, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/freebsd-performance-tip/84071/8 "2006-03-23T20:54:37Z")

</div>

On Mar 20, 2006, at 5:27 AM, Claus G. 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 H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
