From 19ab70e2d0148ca7efbb05bf022d28bd85249920 Mon Sep 17 00:00:00 2001 From: Siqi Chen Date: Fri, 18 Aug 2017 22:42:18 -0700 Subject: [PATCH] Ensure GC for APC happens when normal and eager GC request at same time Summary: Ensure GC for APC happens, when eager GC Reviewed By: edwinsmith Differential Revision: D5555209 fbshipit-source-id: 3c85b7ef0bc1cf28a9f6c0f5de3ed715e5c1ff44 --- hphp/runtime/base/apc-gc-manager.cpp | 4 ++++ hphp/runtime/base/apc-gc-manager.h | 1 + hphp/runtime/base/heap-collect.cpp | 10 +++++++++- hphp/test/slow/apc-OOM.php.opts | 1 - 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hphp/runtime/base/apc-gc-manager.cpp b/hphp/runtime/base/apc-gc-manager.cpp index 52895d83e9b..cdb29851394 100644 --- a/hphp/runtime/base/apc-gc-manager.cpp +++ b/hphp/runtime/base/apc-gc-manager.cpp @@ -68,6 +68,10 @@ void APCGCManager::registerPendingDeletion(APCHandle* root, const size_t size) { } } +bool APCGCManager::excessedGCTriggerBar() { + return pendingSize.load() > someBar(); +} + void APCGCManager::sweep() { assertx(RuntimeOption::EvalGCForAPC); if (RuntimeOption::ServerExecutionMode()) { diff --git a/hphp/runtime/base/apc-gc-manager.h b/hphp/runtime/base/apc-gc-manager.h index 38f859e58dd..ee941920104 100644 --- a/hphp/runtime/base/apc-gc-manager.h +++ b/hphp/runtime/base/apc-gc-manager.h @@ -99,6 +99,7 @@ struct APCGCManager { } // To be global unique static APCGCManager& getInstance(); + bool excessedGCTriggerBar(); private: void invokeGlobalGC(); diff --git a/hphp/runtime/base/heap-collect.cpp b/hphp/runtime/base/heap-collect.cpp index 971e6e54b3e..1a0b6256c55 100644 --- a/hphp/runtime/base/heap-collect.cpp +++ b/hphp/runtime/base/heap-collect.cpp @@ -486,7 +486,15 @@ void collectImpl(HeapImpl& heap, const char* phase) { if (t_eager_gc && RuntimeOption::EvalFilterGCPoints) { t_eager_gc = false; auto pc = vmpc(); - if (t_surprise_filter.test(pc)) return; + if (t_surprise_filter.test(pc)) { + if (RuntimeOption::EvalGCForAPC) { + if (!APCGCManager::getInstance().excessedGCTriggerBar()) { + return; + } + } else { + return; + } + } t_surprise_filter.insert(pc); TRACE(2, "eager gc %s at %p\n", phase, pc); phase = "eager"; diff --git a/hphp/test/slow/apc-OOM.php.opts b/hphp/test/slow/apc-OOM.php.opts index 7aa61d88776..fdd6fcc1fad 100644 --- a/hphp/test/slow/apc-OOM.php.opts +++ b/hphp/test/slow/apc-OOM.php.opts @@ -1,4 +1,3 @@ -vServer.APC.MemModelTreadmill=true -vEval.GCForAPC=true -vEval.EnableGC=1 --vEval.EagerGC=0 -- 2.11.4.GIT