From 518ae2c608faac4a9deae15e50c307d72d629ac4 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 19 Nov 2013 14:58:27 +1100 Subject: [PATCH] added a minimal number of free slots that should always exist --- lib/middleware/unicorn_oobgc.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/middleware/unicorn_oobgc.rb b/lib/middleware/unicorn_oobgc.rb index b0f7bc75910..60c557afe74 100644 --- a/lib/middleware/unicorn_oobgc.rb +++ b/lib/middleware/unicorn_oobgc.rb @@ -7,6 +7,9 @@ module Middleware::UnicornOobgc MIN_REQUESTS_PER_OOBGC = 3 + # TUNE ME, for Discourse this number is good + MIN_FREE_SLOTS = 80_000 + def verbose(msg=nil) @verbose ||= ENV["OOBGC_VERBOSE"] == "1" ? :true : :false if @verbose == :true @@ -66,6 +69,10 @@ module Middleware::UnicornOobgc @max_delta = [new_delta, delta].max end + if @max_delta < MIN_FREE_SLOTS + @max_delta = MIN_FREE_SLOTS + end + if @num_requests > MIN_REQUESTS_PER_OOBGC && @max_delta * 2 + new_live_num > @expect_gc_at t = Time.now GC.start