[Mongrel] garbage collection patch

Evan Weaver evan at cloudbur.st
Wed Feb 6 03:17:44 EST 2008

Disabling GC around the requests would guarantee that the size of the
Mongrel process will balloon to the size of all objects combined in
the most heavyweight request. Remember that the Ruby heap never
returns space to the OS. As soon as you re-enable the GC, the entire
Ruby heap (now 4-5x bigger than it normally would be) will get paged
back in to physical RAM.

As I understand it, the point of disabling the GC is to allow part of
the heap to swap out. This has no benefit if you enable the GC
after--you have to disable the GC, Kernel.fork, run the request, let
the request thread die, and then re-enable the heap in the parent.
This gets you some marginal COW benefit at the cost of having to page
out lots of useless pages while the request is running.

I'm doubtful that there is much benefit but it deserves some testing.

Incidentally the Ruby heap (and the GC) should have nothing to do with
Imagemagick. Extensions that use malloc() are a totally different


On Feb 6, 2008 1:35 AM, Roger Pack <lists at ruby-forum.com> wrote:
> > Not sure, it's probably not get you far since you'd end up paying for
> > it later anyway.  I'd say try it for one or two actions or as a couple
> > of mongrel handlers and see if it helps you.  You coudl also do it
> > filter style that would let you just do this GC hackery for one request.
> I believe the two things that have been done to combat this "sore spot"
> for rails (that it sometimes GC's more than once per request [1]) are
> 1) patch gc.c so that it collects less frequently [i.e. sets the
> collection frequency to be every 40MB instead of 8).  Kind of hard using
> extensions only :)
> 2) have rails GC only every X requests (fastcgi does this, I think).
> It might make a difference in performance.
> Thoughts?
> [1] http://blog.pluron.com/2008/01/ruby-on-rails-i.html
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

Evan Weaver
Cloudburst, LLC

More information about the Mongrel-users mailing list