diff options
| author | 2019-05-23 17:41:48 -0700 | |
|---|---|---|
| committer | 2020-01-15 16:20:29 -0800 | |
| commit | b28db4abbcc2b56ad33b9782bc5cb56596c3d3cc (patch) | |
| tree | 4ac2d714dbc8dc9a717685284f14d63dee49f583 | |
| parent | eabbf8720c100741e02eedac3b371945bcef68b9 (diff) | |
Resets the refill action/timing info after a pool fill event.
Bug: 132794985
Bug: 146614089
Test: m & flash & launch more apps than USAPs in the pool
Change-Id: I9ee74d76692fa8aeba9c70765b3e8f98ea9105bc
Merged-In: I9ee74d76692fa8aeba9c70765b3e8f98ea9105bc
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteServer.java | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java index c898c0db6690..34ea28172cc7 100644 --- a/core/java/com/android/internal/os/ZygoteServer.java +++ b/core/java/com/android/internal/os/ZygoteServer.java @@ -143,6 +143,12 @@ class ZygoteServer { */ private int mUsapPoolRefillDelayMs = -1; + /** + * If and when we should refill the USAP pool. + */ + private UsapPoolRefillAction mUsapPoolRefillAction; + private long mUsapPoolRefillTriggerTimestamp; + private enum UsapPoolRefillAction { DELAYED, IMMEDIATE, @@ -375,6 +381,8 @@ class ZygoteServer { // are re-enabled in specializeAppProcess. ZygoteHooks.postForkCommon(); + resetUsapRefillState(); + Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); return null; @@ -404,6 +412,11 @@ class ZygoteServer { } } + void resetUsapRefillState() { + mUsapPoolRefillAction = UsapPoolRefillAction.NONE; + mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; + } + /** * Runs the zygote process's select loop. Accepts new connections as * they happen, and reads commands from connections one spawn-request's @@ -416,10 +429,11 @@ class ZygoteServer { socketFDs.add(mZygoteSocket.getFileDescriptor()); peers.add(null); - long usapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; + mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; while (true) { fetchUsapPoolPolicyPropsWithMinInterval(); + mUsapPoolRefillAction = UsapPoolRefillAction.NONE; int[] usapPipeFDs = null; StructPollfd[] pollFDs; @@ -473,11 +487,11 @@ class ZygoteServer { int pollTimeoutMs; - if (usapPoolRefillTriggerTimestamp == INVALID_TIMESTAMP) { + if (mUsapPoolRefillTriggerTimestamp == INVALID_TIMESTAMP) { pollTimeoutMs = -1; } else { int elapsedTimeMs = - (int) (System.currentTimeMillis() - usapPoolRefillTriggerTimestamp); + (int) (System.currentTimeMillis() - mUsapPoolRefillTriggerTimestamp); if (elapsedTimeMs >= mUsapPoolRefillDelayMs) { // Normalize the poll timeout value when the time between one poll event and the @@ -496,13 +510,12 @@ class ZygoteServer { throw new RuntimeException("poll failed", ex); } - UsapPoolRefillAction usapPoolRefillAction = UsapPoolRefillAction.NONE; if (pollReturnValue == 0) { // The poll timeout has been exceeded. This only occurs when we have finished the // USAP pool refill delay period. - usapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; - usapPoolRefillAction = UsapPoolRefillAction.DELAYED; + mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; + mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED; } else { boolean usapPoolFDRead = false; @@ -632,15 +645,15 @@ class ZygoteServer { if (usapPoolCount < mUsapPoolSizeMin) { // Immediate refill - usapPoolRefillAction = UsapPoolRefillAction.IMMEDIATE; + mUsapPoolRefillAction = UsapPoolRefillAction.IMMEDIATE; } else if (mUsapPoolSizeMax - usapPoolCount >= mUsapPoolRefillThreshold) { // Delayed refill - usapPoolRefillTriggerTimestamp = System.currentTimeMillis(); + mUsapPoolRefillTriggerTimestamp = System.currentTimeMillis(); } } } - if (usapPoolRefillAction != UsapPoolRefillAction.NONE) { + if (mUsapPoolRefillAction != UsapPoolRefillAction.NONE) { int[] sessionSocketRawFDs = socketFDs.subList(1, socketFDs.size()) .stream() @@ -648,7 +661,7 @@ class ZygoteServer { .toArray(); final boolean isPriorityRefill = - usapPoolRefillAction == UsapPoolRefillAction.IMMEDIATE; + mUsapPoolRefillAction == UsapPoolRefillAction.IMMEDIATE; final Runnable command = fillUsapPool(sessionSocketRawFDs, isPriorityRefill); @@ -657,7 +670,7 @@ class ZygoteServer { return command; } else if (isPriorityRefill) { // Schedule a delayed refill to finish refilling the pool. - usapPoolRefillTriggerTimestamp = System.currentTimeMillis(); + mUsapPoolRefillTriggerTimestamp = System.currentTimeMillis(); } } } |