diff options
Diffstat (limited to 'examples/big_app_gc.rb')
-rw-r--r-- | examples/big_app_gc.rb | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/examples/big_app_gc.rb b/examples/big_app_gc.rb index b4e134f..c4c8b04 100644 --- a/examples/big_app_gc.rb +++ b/examples/big_app_gc.rb @@ -1,31 +1,2 @@ -# Run GC after every request, before attempting to accept more connections. -# -# You could customize this patch to read @request.env["PATH_INFO"] and only -# call GC.start after expensive requests. -# -# We could have this wrap the response body.close as middleware, but the -# scannable stack is would still be bigger than it would be here. -# -# This shouldn't hurt overall performance as long as the server cluster -# is at <=50% CPU capacity, and improves the performance of most memory -# intensive requests. This serves to improve _client-visible_ -# performance (possibly at the cost of overall performance). -# -# We'll call GC after each request is been written out to the socket, so -# the client never sees the extra GC hit it. It's ideal to call the GC -# inside the HTTP server (vs middleware or hooks) since the stack is -# smaller at this point, so the GC will both be faster and more -# effective at releasing unused memory. -# -# This monkey patch is _only_ effective for applications that use a lot -# of memory, and will hurt simpler apps/endpoints that can process -# multiple requests before incurring GC. - -module Unicorn::BigAppGC - def process_client(client) - super - @request.clear - GC.start - end -end -ObjectSpace.each_object(Unicorn::HttpServer) { |s| s.extend(Unicorn::BigAppGC) } +# see {Unicorn::OobGC}[http://unicorn.bogomips.org/Unicorn/OobGC.html] +# Unicorn::OobGC was broken in Unicorn v3.3.1 - v3.6.1 and fixed in v3.6.2 |