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

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

Issue 1100283003: Oilpan: Oilpan's GC should not be triggered without having allocated any object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return false; 509 return false;
510 #if ENABLE(OILPAN) 510 #if ENABLE(OILPAN)
511 // The estimated size is updated when the main thread finishes lazy 511 // The estimated size is updated when the main thread finishes lazy
512 // sweeping. If this thread reaches here before the main thread finishes 512 // sweeping. If this thread reaches here before the main thread finishes
513 // lazy sweeping, the thread will use the estimated size of the last GC. 513 // lazy sweeping, the thread will use the estimated size of the last GC.
514 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 514 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
515 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 515 size_t allocatedObjectSize = Heap::allocatedObjectSize();
516 // Heap::markedObjectSize() may be underestimated if any thread has not 516 // Heap::markedObjectSize() may be underestimated if any thread has not
517 // finished completeSweep(). 517 // finished completeSweep().
518 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 518 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
519 // Schedule an idle GC if the current memory usage is >1MB 519 // Schedule an idle GC if Oilpan has allocated more than 1 MB since
520 // and is >50% larger than the estimated live memory usage. 520 // the last GC and the current memory usage is >50% larger than
521 return currentObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLive ObjectSize * 3 / 2; 521 // the estimated live memory usage.
522 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
522 #else 523 #else
523 return false; 524 return false;
524 #endif 525 #endif
525 } 526 }
526 527
527 // TODO(haraken): We should improve the GC heuristics. 528 // TODO(haraken): We should improve the GC heuristics.
528 // These heuristics affect performance significantly. 529 // These heuristics affect performance significantly.
529 bool ThreadState::shouldSchedulePreciseGC() 530 bool ThreadState::shouldSchedulePreciseGC()
530 { 531 {
531 if (gcState() != NoGCScheduled) 532 if (gcState() != NoGCScheduled)
532 return false; 533 return false;
533 #if ENABLE(OILPAN) 534 #if ENABLE(OILPAN)
534 return false; 535 return false;
535 #else 536 #else
536 // The estimated size is updated when the main thread finishes lazy 537 // The estimated size is updated when the main thread finishes lazy
537 // sweeping. If this thread reaches here before the main thread finishes 538 // 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. 539 // lazy sweeping, the thread will use the estimated size of the last GC.
539 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 540 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
540 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 541 size_t allocatedObjectSize = Heap::allocatedObjectSize();
541 // Heap::markedObjectSize() may be underestimated if any thread has not 542 // Heap::markedObjectSize() may be underestimated if any thread has not
542 // finished completeSweep(). 543 // finished completeSweep().
543 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 544 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
544 // Schedule a precise GC if the current memory usage is >1MB 545 // Schedule a precise GC if Oilpan has allocated more than 1 MB since
545 // and is >50% larger than the estimated live memory usage. 546 // the last GC and the current memory usage is >50% larger than
546 return currentObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLive ObjectSize * 3 / 2; 547 // the estimated live memory usage.
548 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi veObjectSize * 3 / 2;
547 #endif 549 #endif
548 } 550 }
549 551
550 // TODO(haraken): We should improve the GC heuristics. 552 // TODO(haraken): We should improve the GC heuristics.
551 // These heuristics affect performance significantly. 553 // These heuristics affect performance significantly.
552 bool ThreadState::shouldForceConservativeGC() 554 bool ThreadState::shouldForceConservativeGC()
553 { 555 {
554 if (UNLIKELY(m_gcForbiddenCount)) 556 if (UNLIKELY(m_gcForbiddenCount))
555 return false; 557 return false;
556 558
557 // The estimated size is updated when the main thread finishes lazy 559 // The estimated size is updated when the main thread finishes lazy
558 // sweeping. If this thread reaches here before the main thread finishes 560 // sweeping. If this thread reaches here before the main thread finishes
559 // 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.
560 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); 562 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize();
561 size_t allocatedObjectSize = Heap::allocatedObjectSize(); 563 size_t allocatedObjectSize = Heap::allocatedObjectSize();
562 // Heap::markedObjectSize() may be underestimated if any thread has not 564 // Heap::markedObjectSize() may be underestimated if any thread has not
563 // finished completeSweep(). 565 // finished completeSweep().
564 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages(); 566 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() + WTF::Partitions::totalSizeOfCommittedPages();
565 if (currentObjectSize >= 300 * 1024 * 1024) { 567 if (currentObjectSize >= 300 * 1024 * 1024) {
566 // If we're consuming too much memory, trigger a conservative GC 568 // If we're consuming too much memory, trigger a conservative GC
567 // aggressively. This is a safe guard to avoid OOM. 569 // aggressively. This is a safe guard to avoid OOM.
568 return currentObjectSize > estimatedLiveObjectSize * 3 / 2; 570 return currentObjectSize > estimatedLiveObjectSize * 3 / 2;
569 } 571 }
570 // Schedule a conservative GC if the current memory usage is >32MB 572 // Schedule a conservative GC if Oilpan has allocated more than 32 MB since
571 // and is >400% larger than the estimated live memory usage. 573 // the last GC and the current memory usage is >400% larger than
574 // the estimated live memory usage.
572 // TODO(haraken): 400% is too large. Lower the heap growing factor. 575 // TODO(haraken): 400% is too large. Lower the heap growing factor.
573 return currentObjectSize >= 32 * 1024 * 1024 && currentObjectSize > 5 * esti matedLiveObjectSize; 576 return allocatedObjectSize >= 32 * 1024 * 1024 && currentObjectSize > 5 * es timatedLiveObjectSize;
574 } 577 }
575 578
576 void ThreadState::scheduleGCIfNeeded() 579 void ThreadState::scheduleGCIfNeeded()
577 { 580 {
578 checkThread(); 581 checkThread();
579 // Allocation is allowed during sweeping, but those allocations should not 582 // Allocation is allowed during sweeping, but those allocations should not
580 // trigger nested GCs. 583 // trigger nested GCs.
581 if (isSweepingInProgress()) 584 if (isSweepingInProgress())
582 return; 585 return;
583 ASSERT(!sweepForbidden()); 586 ASSERT(!sweepForbidden());
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 json->beginArray(it->key.ascii().data()); 1299 json->beginArray(it->key.ascii().data());
1297 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1300 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1298 json->pushInteger(it->value.ages[age]); 1301 json->pushInteger(it->value.ages[age]);
1299 json->endArray(); 1302 json->endArray();
1300 } 1303 }
1301 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1304 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1302 } 1305 }
1303 #endif 1306 #endif
1304 1307
1305 } // namespace blink 1308 } // 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