Peformance up - using OobGC & GC.disable

secondlife hotchpotch at gmail.com
Tue Oct 4 03:10:38 EDT 2011


Hi,
I'm working at Cookpad Inc.

- http://cookpad.com/

Cookpad is very famous cooking recipe service in Japan,
and largest rails application in Japan.

I applied GC.disable after fork, and a few changed Unicorn::OobGC.

# unicorn.conf.rb
 after_fork do |server, worker|
  GC.disable if RAILS_ENV == 'production'

# OobGC code
 def process_client(client)
  super(client) # Unicorn::HttpServer#process_client
  if OOBGC_PATH =~ OOBGC_ENV[PATH_INFO] && ((@@nr -= 1) <= 0)
    @@nr = OOBGC_INTERVAL
    OOBGC_ENV.clear
    disabled = GC.enable
    GC.start
    GC.disable if disabled
  end
 end

after applied,
application response time 130% fast!
and CPU usage to half!

- http://bit.ly/rhnVlg (response time)
- http://bit.ly/pgMN06 (CPU usage)

This is OobGC patch, apply please.
- http://bit.ly/roVLtZ (patch)

Also, my rails application have memory leaks ;(
I wrote process killing code because GC.disable create more memory leak.
- https://gist.github.com/1258681

------------------------------------------
Yuichi Tateno
https://github.com/hotchpotch


More information about the mongrel-unicorn mailing list