Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: Source/platform/heap/ThreadState.cpp

Issue 1156863002: Oilpan: Tweak a GC threshold to consider memory increase in PartitionAlloc Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 return false; 532 return false;
533 #if ENABLE(OILPAN) 533 #if ENABLE(OILPAN)
534 // The estimated size is updated when the main thread finishes lazy 534 // The estimated size is updated when the main thread finishes lazy
535 // sweeping. If this thread reaches here before the main thread finishes 535 // sweeping. If this thread reaches here before the main thread finishes
536 // lazy sweeping, the thread will use the estimated size of the last GC. 536 // lazy sweeping, the thread will use the estimated size of the last GC.
537 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 537 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
538 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 538 size_t allocatedObjectSize = Heap::allocatedObjectSize();
539 // Heap::markedObjectSize() may be underestimated if any thread has not 539 // Heap::markedObjectSize() may be underestimated if any thread has not
540 // finished completeSweep(). 540 // finished completeSweep().
541 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 541 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
542 // Schedule an idle GC if Oilpan has allocated more than 1 MB since 542 // Schedule an idle GC if Oilpan has allocated more than 1 MB and the
543 // the last GC and the current memory usage is >50% larger than 543 // current memory usage is >50% larger than the estimated live memory usage.
544 // the estimated live memory usage. 544 return Heap::allocatedSpace() >= 1024 * 1024 && currentObjectSize > estimate dLiveObjectSize * 3 / 2;
545 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
546 #else 545 #else
547 return false; 546 return false;
548 #endif 547 #endif
549 } 548 }
550 549
551 // TODO(haraken): We should improve the GC heuristics. 550 // TODO(haraken): We should improve the GC heuristics.
552 // These heuristics affect performance significantly. 551 // These heuristics affect performance significantly.
553 bool ThreadState::shouldSchedulePreciseGC() 552 bool ThreadState::shouldSchedulePreciseGC()
554 { 553 {
555 if (gcState() != NoGCScheduled) 554 if (gcState() != NoGCScheduled)
556 return false; 555 return false;
557 #if ENABLE(OILPAN) 556 #if ENABLE(OILPAN)
558 return false; 557 return false;
559 #else 558 #else
560 // The estimated size is updated when the main thread finishes lazy 559 // The estimated size is updated when the main thread finishes lazy
561 // sweeping. If this thread reaches here before the main thread finishes 560 // sweeping. If this thread reaches here before the main thread finishes
562 // lazy sweeping, the thread will use the estimated size of the last GC. 561 // lazy sweeping, the thread will use the estimated size of the last GC.
563 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 562 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
564 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 563 size_t allocatedObjectSize = Heap::allocatedObjectSize();
565 // Heap::markedObjectSize() may be underestimated if any thread has not 564 // Heap::markedObjectSize() may be underestimated if any thread has not
566 // finished completeSweep(). 565 // finished completeSweep().
567 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 566 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
568 // Schedule a precise GC if Oilpan has allocated more than 1 MB since 567 // Schedule a precise GC if Oilpan has allocated more than 1 MB and the
569 // the last GC and the current memory usage is >50% larger than 568 // current memory usage is >50% larger than the estimated live memory usage.
570 // the estimated live memory usage. 569 return Heap::allocatedSpace() >= 1024 * 1024 && currentObjectSize > estimate dLiveObjectSize * 3 / 2;
571 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
572 #endif 570 #endif
573 } 571 }
574 572
575 // TODO(haraken): We should improve the GC heuristics. 573 // TODO(haraken): We should improve the GC heuristics.
576 // These heuristics affect performance significantly. 574 // These heuristics affect performance significantly.
577 bool ThreadState::shouldForceConservativeGC() 575 bool ThreadState::shouldForceConservativeGC()
578 { 576 {
579 if (UNLIKELY(isGCForbidden())) 577 if (UNLIKELY(isGCForbidden()))
580 return false; 578 return false;
581 579
582 // The estimated size is updated when the main thread finishes lazy 580 // The estimated size is updated when the main thread finishes lazy
583 // sweeping. If this thread reaches here before the main thread finishes 581 // sweeping. If this thread reaches here before the main thread finishes
584 // lazy sweeping, the thread will use the estimated size of the last GC. 582 // lazy sweeping, the thread will use the estimated size of the last GC.
585 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 583 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
586 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 584 size_t allocatedObjectSize = Heap::allocatedObjectSize();
587 // Heap::markedObjectSize() may be underestimated if any thread has not 585 // Heap::markedObjectSize() may be underestimated if any thread has not
588 // finished completeSweep(). 586 // finished completeSweep().
589 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 587 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
590 if (currentObjectSize >= 300 * 1024 * 1024) { 588 if (currentObjectSize >= 300 * 1024 * 1024) {
591 // If we're consuming too much memory, trigger a conservative GC 589 // If we're consuming too much memory, trigger a conservative GC
592 // aggressively. This is a safe guard to avoid OOM. 590 // aggressively. This is a safe guard to avoid OOM.
593 return currentObjectSize > estimatedLiveObjectSize * 3 / 2; 591 return currentObjectSize > estimatedLiveObjectSize * 3 / 2;
sof 2015/06/09 15:49:56 If size_t is 4 bytes wide (win32), the computation
594 } 592 }
595 // Schedule a conservative GC if Oilpan has allocated more than 32 MB since 593 // Schedule a conservative GC if Oilpan has allocated more than 32 MB and
596 // the last GC and the current memory usage is >400% larger than 594 // the current memory usage is >400% larger than the estimated live memory
597 // the estimated live memory usage. 595 // usage.
598 // TODO(haraken): 400% is too large. Lower the heap growing factor. 596 // TODO(haraken): 400% is too large. Lower the heap growing factor.
599 return allocatedObjectSize >= 32 * 1024 * 1024 && currentObjectSize > 5 * es timatedLiveObjectSize; 597 return Heap::allocatedSpace() >= 32 * 1024 * 1024 && currentObjectSize > 5 * estimatedLiveObjectSize;
600 } 598 }
601 599
602 void ThreadState::scheduleGCIfNeeded() 600 void ThreadState::scheduleGCIfNeeded()
603 { 601 {
604 checkThread(); 602 checkThread();
605 // Allocation is allowed during sweeping, but those allocations should not 603 // Allocation is allowed during sweeping, but those allocations should not
606 // trigger nested GCs. 604 // trigger nested GCs.
607 if (isSweepingInProgress()) 605 if (isSweepingInProgress())
608 return; 606 return;
609 ASSERT(!sweepForbidden()); 607 ASSERT(!sweepForbidden());
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 json->beginArray(it->key.ascii().data()); 1350 json->beginArray(it->key.ascii().data());
1353 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1351 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1354 json->pushInteger(it->value.ages[age]); 1352 json->pushInteger(it->value.ages[age]);
1355 json->endArray(); 1353 json->endArray();
1356 } 1354 }
1357 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1355 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1358 } 1356 }
1359 #endif 1357 #endif
1360 1358
1361 } // namespace blink 1359 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698