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

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, 7 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return false; 508 return false;
509 #if ENABLE(OILPAN) 509 #if ENABLE(OILPAN)
510 // The estimated size is updated when the main thread finishes lazy 510 // The estimated size is updated when the main thread finishes lazy
511 // sweeping. If this thread reaches here before the main thread finishes 511 // sweeping. If this thread reaches here before the main thread finishes
512 // lazy sweeping, the thread will use the estimated size of the last GC. 512 // lazy sweeping, the thread will use the estimated size of the last GC.
513 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 513 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
514 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 514 size_t allocatedObjectSize = Heap::allocatedObjectSize();
515 // Heap::markedObjectSize() may be underestimated if any thread has not 515 // Heap::markedObjectSize() may be underestimated if any thread has not
516 // finished completeSweep(). 516 // finished completeSweep().
517 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 517 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
518 // Schedule an idle GC if Oilpan has allocated more than 1 MB since 518 return Heap::allocatedSpace() >= 1024 * 1024 // Oilpan has allocated >1 MB.
519 // the last GC and the current memory usage is >50% larger than 519 && currentObjectSize >= 1024 * 1024 // Oilpan or/and PartitionAlloc have allocated >1 MB since the last GC.
sof 2015/05/25 21:37:51 If allocatedObjectSize >= 1024 * 1024, doesn't tha
haraken 2015/05/25 23:31:53 Yes. - allocatedObjectSize >= 1 MB implies curren
sof 2015/05/26 05:10:59 Oops, quite right - I didn't pick the suffixes apa
520 // the estimated live memory usage. 520 && currentObjectSize > estimatedLiveObjectSize * 3 / 2; // The current m emory usage is >50% larger than the estimated live memory usage.
521 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
522 #else 521 #else
523 return false; 522 return false;
524 #endif 523 #endif
525 } 524 }
526 525
527 // TODO(haraken): We should improve the GC heuristics. 526 // TODO(haraken): We should improve the GC heuristics.
528 // These heuristics affect performance significantly. 527 // These heuristics affect performance significantly.
529 bool ThreadState::shouldSchedulePreciseGC() 528 bool ThreadState::shouldSchedulePreciseGC()
530 { 529 {
531 if (gcState() != NoGCScheduled) 530 if (gcState() != NoGCScheduled)
532 return false; 531 return false;
533 #if ENABLE(OILPAN) 532 #if ENABLE(OILPAN)
534 return false; 533 return false;
535 #else 534 #else
536 // The estimated size is updated when the main thread finishes lazy 535 // The estimated size is updated when the main thread finishes lazy
537 // sweeping. If this thread reaches here before the main thread finishes 536 // sweeping. If this thread reaches here before the main thread finishes
538 // lazy sweeping, the thread will use the estimated size of the last GC. 537 // lazy sweeping, the thread will use the estimated size of the last GC.
539 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 538 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
540 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 539 size_t allocatedObjectSize = Heap::allocatedObjectSize();
541 // Heap::markedObjectSize() may be underestimated if any thread has not 540 // Heap::markedObjectSize() may be underestimated if any thread has not
542 // finished completeSweep(). 541 // finished completeSweep().
543 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 542 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
544 // Schedule a precise GC if Oilpan has allocated more than 1 MB since 543 return Heap::allocatedSpace() >= 1024 * 1024 // Oilpan has allocated >1 MB.
545 // the last GC and the current memory usage is >50% larger than 544 && currentObjectSize >= 1024 * 1024 // Oilpan or/and PartitionAlloc have allocated >1 MB since the last GC.
sof 2015/05/26 19:25:37 Is this really true? totalSizeOfCommittedPages() d
haraken 2015/05/27 00:39:00 You're right; this comment is wrong. It should be:
sof 2015/05/27 05:09:07 Not just the comment is wrong; this seems like cur
haraken 2015/05/27 05:50:03 There would be various opinions, but IMO this is a
546 // the estimated live memory usage. 545 && currentObjectSize > estimatedLiveObjectSize * 3 / 2; // The current m emory usage is >50% larger than the estimated live memory usage.
547 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
548 #endif 546 #endif
549 } 547 }
550 548
551 // TODO(haraken): We should improve the GC heuristics. 549 // TODO(haraken): We should improve the GC heuristics.
552 // These heuristics affect performance significantly. 550 // These heuristics affect performance significantly.
553 bool ThreadState::shouldForceConservativeGC() 551 bool ThreadState::shouldForceConservativeGC()
554 { 552 {
555 if (UNLIKELY(isGCForbidden())) 553 if (UNLIKELY(isGCForbidden()))
556 return false; 554 return false;
557 555
558 // The estimated size is updated when the main thread finishes lazy 556 // The estimated size is updated when the main thread finishes lazy
559 // sweeping. If this thread reaches here before the main thread finishes 557 // sweeping. If this thread reaches here before the main thread finishes
560 // lazy sweeping, the thread will use the estimated size of the last GC. 558 // lazy sweeping, the thread will use the estimated size of the last GC.
561 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 559 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
562 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 560 size_t allocatedObjectSize = Heap::allocatedObjectSize();
563 // Heap::markedObjectSize() may be underestimated if any thread has not 561 // Heap::markedObjectSize() may be underestimated if any thread has not
564 // finished completeSweep(). 562 // finished completeSweep().
565 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 563 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
566 if (currentObjectSize >= 300 * 1024 * 1024) { 564 if (currentObjectSize >= 300 * 1024 * 1024) {
567 // If we're consuming too much memory, trigger a conservative GC 565 // If we're consuming too much memory, trigger a conservative GC
568 // aggressively. This is a safe guard to avoid OOM. 566 // aggressively. This is a safe guard to avoid OOM.
569 return currentObjectSize > estimatedLiveObjectSize * 3 / 2; 567 return currentObjectSize > estimatedLiveObjectSize * 3 / 2;
570 } 568 }
571 // Schedule a conservative GC if Oilpan has allocated more than 32 MB since 569 return Heap::allocatedSpace() >= 1024 * 1024 // Oilpan has allocated >1 MB.
572 // the last GC and the current memory usage is >400% larger than 570 && currentObjectSize >= 32 * 1024 * 1024 // Oilpan or/and PartitionAlloc have allocated >32 MB since the last GC.
573 // the estimated live memory usage. 571 && currentObjectSize > estimatedLiveObjectSize * 5; // The current memor y usage is >400% larger than the estimated live memory usage. TODO(haraken): 400 % is too large. Lower the heap growing factor.
574 // TODO(haraken): 400% is too large. Lower the heap growing factor.
575 return allocatedObjectSize >= 32 * 1024 * 1024 && currentObjectSize > 5 * es timatedLiveObjectSize;
576 } 572 }
577 573
578 void ThreadState::scheduleGCIfNeeded() 574 void ThreadState::scheduleGCIfNeeded()
579 { 575 {
580 checkThread(); 576 checkThread();
581 // Allocation is allowed during sweeping, but those allocations should not 577 // Allocation is allowed during sweeping, but those allocations should not
582 // trigger nested GCs. 578 // trigger nested GCs.
583 if (isSweepingInProgress()) 579 if (isSweepingInProgress())
584 return; 580 return;
585 ASSERT(!sweepForbidden()); 581 ASSERT(!sweepForbidden());
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 json->beginArray(it->key.ascii().data()); 1324 json->beginArray(it->key.ascii().data());
1329 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1325 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1330 json->pushInteger(it->value.ages[age]); 1326 json->pushInteger(it->value.ages[age]);
1331 json->endArray(); 1327 json->endArray();
1332 } 1328 }
1333 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1329 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1334 } 1330 }
1335 #endif 1331 #endif
1336 1332
1337 } // namespace blink 1333 } // 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