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 void ThreadState::schedulePageNavigationGCIfNeeded(float estimatedRemovalRatio) | |
| 654 { | |
|
haraken
2015/08/06 07:52:43
Add:
if (UNLIKELY(isGCForbidden()))
return
keishi
2015/08/11 06:59:53
Done.
| |
| 655 // Avoid potential overflow by truncating to Kb. | |
| 656 size_t allocatedObjectSizeKb = Heap::allocatedObjectSize() >> 10; | |
| 657 // The estimated size is updated when the main thread finishes lazy | |
| 658 // sweeping. If this thread reaches here before the main thread finishes | |
| 659 // lazy sweeping, the thread will use the estimated size of the last GC. | |
| 660 size_t estimatedLiveObjectSizeKb = (estimatedLiveObjectSize() >> 10) * (1 - estimatedRemovalRatio); | |
| 661 // Heap::markedObjectSize() may be underestimated if any thread has not | |
| 662 // finished completeSweep(). | |
| 663 size_t currentObjectSizeKb = currentObjectSize() >> 10; | |
| 664 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | |
| 665 // the last GC and the current memory usage is >50% larger than | |
| 666 // the estimated live memory usage. | |
| 667 if (allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLiveObj ectSizeKb * 3) / 2) | |
| 668 schedulePreciseGC(); | |
| 669 } | |
|
haraken
2015/08/06 07:52:42
bool ThreadState::shouldSchedulePageNavigationGC(f
keishi
2015/08/11 06:59:53
Done.
| |
| 670 | |
| 653 // TODO(haraken): We should improve the GC heuristics. | 671 // TODO(haraken): We should improve the GC heuristics. |
| 654 // These heuristics affect performance significantly. | 672 // These heuristics affect performance significantly. |
| 655 bool ThreadState::shouldForceConservativeGC() | 673 bool ThreadState::shouldForceConservativeGC() |
| 656 { | 674 { |
| 657 if (UNLIKELY(isGCForbidden())) | 675 if (UNLIKELY(isGCForbidden())) |
| 658 return false; | 676 return false; |
| 659 | 677 |
| 660 if (shouldForceMemoryPressureGC()) | 678 if (shouldForceMemoryPressureGC()) |
| 661 return true; | 679 return true; |
| 662 | 680 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 // Prevent that from happening by marking GCs as forbidden while | 919 // Prevent that from happening by marking GCs as forbidden while |
| 902 // one is initiated and later running. | 920 // one is initiated and later running. |
| 903 if (isGCForbidden()) | 921 if (isGCForbidden()) |
| 904 return; | 922 return; |
| 905 | 923 |
| 906 switch (gcState()) { | 924 switch (gcState()) { |
| 907 case FullGCScheduled: | 925 case FullGCScheduled: |
| 908 Heap::collectAllGarbage(); | 926 Heap::collectAllGarbage(); |
| 909 break; | 927 break; |
| 910 case PreciseGCScheduled: | 928 case PreciseGCScheduled: |
| 911 Heap::collectGarbage(NoHeapPointersOnStack, GCWithoutSweep, Heap::Precis eGC); | 929 Heap::collectGarbage(NoHeapPointersOnStack, GCWithSweep, Heap::PreciseGC ); |
|
haraken
2015/08/06 07:52:43
Hmm, I'm fine with forcing sweeping for navigation
keishi
2015/08/11 06:59:53
Done.
| |
| 912 break; | 930 break; |
| 913 case IdleGCScheduled: | 931 case IdleGCScheduled: |
| 914 // Idle time GC will be scheduled by Blink Scheduler. | 932 // Idle time GC will be scheduled by Blink Scheduler. |
| 915 break; | 933 break; |
| 916 default: | 934 default: |
| 917 break; | 935 break; |
| 918 } | 936 } |
| 919 } | 937 } |
| 920 | 938 |
| 921 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() | 939 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 json->beginArray(it->key.ascii().data()); | 1549 json->beginArray(it->key.ascii().data()); |
| 1532 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1550 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1533 json->pushInteger(it->value.ages[age]); | 1551 json->pushInteger(it->value.ages[age]); |
| 1534 json->endArray(); | 1552 json->endArray(); |
| 1535 } | 1553 } |
| 1536 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1554 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
| 1537 } | 1555 } |
| 1538 #endif | 1556 #endif |
| 1539 | 1557 |
| 1540 } // namespace blink | 1558 } // namespace blink |
| OLD | NEW |