Commit ecda5d85 authored by Ian Rogers's avatar Ian Rogers Committed by android code review
Browse files

Merge "Fix for 6994917 GC is slower since JOO33B per FrameworkPerf test"

parents b48569ac 33c8ae5b
......@@ -512,7 +512,12 @@ u8 dvmGetOtherThreadCpuTimeNsec(pthread_t thread)
*/
bool dvmIterativeSleep(int iteration, int maxTotalSleep, u8 relStartTime)
{
const int minSleep = 10000;
/*
* Minimum sleep is one millisecond, it is important to keep this value
* low to ensure short GC pauses since dvmSuspendAllThreads() uses this
* function.
*/
const int minSleep = 1000;
u8 curTime;
int curDelay;
......
......@@ -204,17 +204,13 @@ static void *tryMalloc(size_t size)
* lock, wait for the GC to complete, and retrying allocating.
*/
dvmWaitForConcurrentGcToComplete();
ptr = dvmHeapSourceAlloc(size);
if (ptr != NULL) {
return ptr;
}
} else {
/*
* Try a foreground GC since a concurrent GC is not currently running.
*/
gcForMalloc(false);
}
/*
* Another failure. Our thread was starved or there may be too
* many live objects. Try a foreground GC. This will have no
* effect if the concurrent GC is already running.
*/
gcForMalloc(false);
ptr = dvmHeapSourceAlloc(size);
if (ptr != NULL) {
return ptr;
......@@ -701,8 +697,9 @@ void dvmCollectGarbageInternal(const GcSpec* spec)
* suspend when the GC thread calls dvmUnlockHeap before dvmResumeAllThreads,
* but there's no risk of deadlock.)
*/
void dvmWaitForConcurrentGcToComplete()
bool dvmWaitForConcurrentGcToComplete()
{
bool waited = gDvm.gcHeap->gcRunning;
Thread *self = dvmThreadSelf();
assert(self != NULL);
u4 start = dvmGetRelativeTimeMsec();
......@@ -715,4 +712,5 @@ void dvmWaitForConcurrentGcToComplete()
if (end - start > 0) {
ALOGD("WAIT_FOR_CONCURRENT_GC blocked %ums", end - start);
}
return waited;
}
......@@ -92,7 +92,7 @@ void dvmCollectGarbageInternal(const GcSpec *spec);
* re-acquires the heap lock. After returning, no garbage collection
* will be in progress and the heap lock will be held by the caller.
*/
void dvmWaitForConcurrentGcToComplete(void);
bool dvmWaitForConcurrentGcToComplete(void);
/*
* Returns true iff <obj> points to a valid allocated object.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment