Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 // Heap::markedObjectSize() may be underestimated if any thread has not | 643 // Heap::markedObjectSize() may be underestimated if any thread has not |
| 644 // finished completeSweep(). | 644 // finished completeSweep(). |
| 645 size_t currentObjectSizeKb = currentObjectSize() >> 10; | 645 size_t currentObjectSizeKb = currentObjectSize() >> 10; |
| 646 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | 646 // Schedule a precise GC if Oilpan has allocated more than 1 MB since |
| 647 // the last GC and the current memory usage is >50% larger than | 647 // the last GC and the current memory usage is >50% larger than |
| 648 // the estimated live memory usage. | 648 // the estimated live memory usage. |
| 649 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; | 649 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; |
| 650 #endif | 650 #endif |
| 651 } | 651 } |
| 652 | 652 |
| 653 bool ThreadState::shouldSchedulePageNavigationGC(float estimatedRemovalRatio) | |
| 654 { | |
| 655 if (UNLIKELY(isGCForbidden())) | |
| 656 return false; | |
| 657 | |
| 658 if (shouldForceMemoryPressureGC()) | |
| 659 return true; | |
| 660 | |
| 661 // Avoid potential overflow by truncating to Kb. | |
| 662 size_t allocatedObjectSizeKb = Heap::allocatedObjectSize() >> 10; | |
| 663 // The estimated size is updated when the main thread finishes lazy | |
| 664 // sweeping. If this thread reaches here before the main thread finishes | |
| 665 // lazy sweeping, the thread will use the estimated size of the last GC. | |
| 666 size_t estimatedLiveObjectSizeKb = (estimatedLiveObjectSize() >> 10) * (1 - estimatedRemovalRatio); | |
| 667 // Heap::markedObjectSize() may be underestimated if any thread has not | |
| 668 // finished completeSweep(). | |
| 669 size_t currentObjectSizeKb = currentObjectSize() >> 10; | |
| 670 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | |
| 671 // the last GC and the current memory usage is >50% larger than | |
| 672 // the estimated live memory usage. | |
| 673 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; | |
| 674 } | |
| 675 | |
| 676 void ThreadState::schedulePageNavigationGCIfNeeded(float estimatedRemovalRatio) | |
| 677 { | |
| 678 ASSERT(checkThread()); | |
| 679 // Finish on-going lazy sweeping. | |
|
haraken
2015/08/11 07:43:08
Add:
// TODO(haraken): It might not make sense
keishi
2015/08/11 08:12:58
Done.
| |
| 680 completeSweep(); | |
| 681 ASSERT(!isSweepingInProgress()); | |
| 682 ASSERT(!sweepForbidden()); | |
| 683 | |
| 684 Heap::reportMemoryUsageForTracing(); | |
| 685 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) | |
| 686 schedulePageNavigationGC(); | |
| 687 } | |
| 688 | |
| 689 void ThreadState::schedulePageNavigationGC() | |
| 690 { | |
| 691 ASSERT(checkThread()); | |
| 692 ASSERT(!isSweepingInProgress()); | |
| 693 setGCState(PageNavigationGCScheduled); | |
| 694 } | |
| 695 | |
| 653 // TODO(haraken): We should improve the GC heuristics. | 696 // TODO(haraken): We should improve the GC heuristics. |
| 654 // These heuristics affect performance significantly. | 697 // These heuristics affect performance significantly. |
| 655 bool ThreadState::shouldForceConservativeGC() | 698 bool ThreadState::shouldForceConservativeGC() |
| 656 { | 699 { |
| 657 if (UNLIKELY(isGCForbidden())) | 700 if (UNLIKELY(isGCForbidden())) |
| 658 return false; | 701 return false; |
| 659 | 702 |
| 660 if (shouldForceMemoryPressureGC()) | 703 if (shouldForceMemoryPressureGC()) |
| 661 return true; | 704 return true; |
| 662 | 705 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 903 if (isGCForbidden()) | 946 if (isGCForbidden()) |
| 904 return; | 947 return; |
| 905 | 948 |
| 906 switch (gcState()) { | 949 switch (gcState()) { |
| 907 case FullGCScheduled: | 950 case FullGCScheduled: |
| 908 Heap::collectAllGarbage(); | 951 Heap::collectAllGarbage(); |
| 909 break; | 952 break; |
| 910 case PreciseGCScheduled: | 953 case PreciseGCScheduled: |
| 911 Heap::collectGarbage(NoHeapPointersOnStack, GCWithoutSweep, Heap::Precis eGC); | 954 Heap::collectGarbage(NoHeapPointersOnStack, GCWithoutSweep, Heap::Precis eGC); |
| 912 break; | 955 break; |
| 956 case PageNavigationGCScheduled: | |
| 957 Heap::collectGarbage(NoHeapPointersOnStack, GCWithSweep, Heap::PreciseGC ); | |
| 958 break; | |
| 913 case IdleGCScheduled: | 959 case IdleGCScheduled: |
| 914 // Idle time GC will be scheduled by Blink Scheduler. | 960 // Idle time GC will be scheduled by Blink Scheduler. |
| 915 break; | 961 break; |
| 916 default: | 962 default: |
| 917 break; | 963 break; |
| 918 } | 964 } |
| 919 } | 965 } |
| 920 | 966 |
| 921 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() | 967 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() |
| 922 { | 968 { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 json->beginArray(it->key.ascii().data()); | 1577 json->beginArray(it->key.ascii().data()); |
| 1532 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1578 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1533 json->pushInteger(it->value.ages[age]); | 1579 json->pushInteger(it->value.ages[age]); |
| 1534 json->endArray(); | 1580 json->endArray(); |
| 1535 } | 1581 } |
| 1536 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1582 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
| 1537 } | 1583 } |
| 1538 #endif | 1584 #endif |
| 1539 | 1585 |
| 1540 } // namespace blink | 1586 } // namespace blink |
| OLD | NEW |