Add oobgc compatible with Ruby 2.1

This commit is contained in:
Sam 2014-02-18 14:09:47 +11:00
parent a74c67e305
commit a6f4d00670
1 changed files with 22 additions and 0 deletions

View File

@ -33,6 +33,22 @@ module Middleware::UnicornOobgc
# TUNE ME, for Discourse this number is good
MIN_FREE_SLOTS = 50_000
# The oobgc implementation is far more efficient in 2.1
# as we have a bunch of profiling hooks to hook it
# use @tmm1s implementation
def use_gctools?
if @use_gctools.nil?
@use_gctools =
if RUBY_VERSION >= "2.1.0"
require "gctools/oobgc"
true
else
false
end
end
@use_gctools
end
def verbose(msg=nil)
@verbose ||= ENV["OOBGC_VERBOSE"] == "1" ? :true : :false
if @verbose == :true
@ -59,6 +75,12 @@ module Middleware::UnicornOobgc
end
def process_client(client)
if use_gctools?
GC::OOB.run
return
end
stat = GC.stat
@num_requests ||= 0