Add oobgc compatible with Ruby 2.1
This commit is contained in:
parent
a74c67e305
commit
a6f4d00670
|
@ -33,6 +33,22 @@ module Middleware::UnicornOobgc
|
||||||
# TUNE ME, for Discourse this number is good
|
# TUNE ME, for Discourse this number is good
|
||||||
MIN_FREE_SLOTS = 50_000
|
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)
|
def verbose(msg=nil)
|
||||||
@verbose ||= ENV["OOBGC_VERBOSE"] == "1" ? :true : :false
|
@verbose ||= ENV["OOBGC_VERBOSE"] == "1" ? :true : :false
|
||||||
if @verbose == :true
|
if @verbose == :true
|
||||||
|
@ -59,6 +75,12 @@ module Middleware::UnicornOobgc
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_client(client)
|
def process_client(client)
|
||||||
|
|
||||||
|
if use_gctools?
|
||||||
|
GC::OOB.run
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
stat = GC.stat
|
stat = GC.stat
|
||||||
|
|
||||||
@num_requests ||= 0
|
@num_requests ||= 0
|
||||||
|
|
Loading…
Reference in New Issue