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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 // Heap::markedObjectSize() may be underestimated if any thread has not | 641 // Heap::markedObjectSize() may be underestimated if any thread has not |
642 // finished completeSweep(). | 642 // finished completeSweep(). |
643 size_t currentObjectSizeKb = currentObjectSize() >> 10; | 643 size_t currentObjectSizeKb = currentObjectSize() >> 10; |
644 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | 644 // Schedule a precise GC if Oilpan has allocated more than 1 MB since |
645 // the last GC and the current memory usage is >50% larger than | 645 // the last GC and the current memory usage is >50% larger than |
646 // the estimated live memory usage. | 646 // the estimated live memory usage. |
647 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; | 647 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; |
648 #endif | 648 #endif |
649 } | 649 } |
650 | 650 |
651 bool ThreadState::shouldSchedulePreciseGCOnNavigation(float estimatedRemovalRati o) | |
652 { | |
653 // Avoid potential overflow by truncating to Kb. | |
654 size_t allocatedObjectSizeKb = Heap::allocatedObjectSize() >> 10; | |
655 // The estimated size is updated when the main thread finishes lazy | |
656 // sweeping. If this thread reaches here before the main thread finishes | |
657 // lazy sweeping, the thread will use the estimated size of the last GC. | |
658 size_t estimatedLiveObjectSizeKb = (estimatedLiveObjectSize() >> 10) * (1 - estimatedRemovalRatio); | |
659 // Heap::markedObjectSize() may be underestimated if any thread has not | |
660 // finished completeSweep(). | |
661 size_t currentObjectSizeKb = currentObjectSize() >> 10; | |
662 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | |
663 // the last GC and the current memory usage is >50% larger than | |
664 // the estimated live memory usage. | |
665 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive ObjectSizeKb * 3) / 2; | |
666 } | |
667 | |
651 // TODO(haraken): We should improve the GC heuristics. | 668 // TODO(haraken): We should improve the GC heuristics. |
652 // These heuristics affect performance significantly. | 669 // These heuristics affect performance significantly. |
653 bool ThreadState::shouldForceConservativeGC() | 670 bool ThreadState::shouldForceConservativeGC() |
654 { | 671 { |
655 if (UNLIKELY(isGCForbidden())) | 672 if (UNLIKELY(isGCForbidden())) |
656 return false; | 673 return false; |
657 | 674 |
658 if (shouldForceMemoryPressureGC()) | 675 if (shouldForceMemoryPressureGC()) |
659 return true; | 676 return true; |
660 | 677 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 // Prevent that from happening by marking GCs as forbidden while | 916 // Prevent that from happening by marking GCs as forbidden while |
900 // one is initiated and later running. | 917 // one is initiated and later running. |
901 if (isGCForbidden()) | 918 if (isGCForbidden()) |
902 return; | 919 return; |
903 | 920 |
904 switch (gcState()) { | 921 switch (gcState()) { |
905 case FullGCScheduled: | 922 case FullGCScheduled: |
906 Heap::collectAllGarbage(); | 923 Heap::collectAllGarbage(); |
907 break; | 924 break; |
908 case PreciseGCScheduled: | 925 case PreciseGCScheduled: |
909 Heap::collectGarbage(NoHeapPointersOnStack, GCWithoutSweep, Heap::Precis eGC); | 926 Heap::collectGarbage(NoHeapPointersOnStack, GCWithSweep, Heap::PreciseGC ); |
haraken
2015/08/03 01:03:59
Maybe is the regression you're observing in the sh
| |
910 break; | 927 break; |
911 case IdleGCScheduled: | 928 case IdleGCScheduled: |
912 // Idle time GC will be scheduled by Blink Scheduler. | 929 // Idle time GC will be scheduled by Blink Scheduler. |
913 break; | 930 break; |
914 default: | 931 default: |
915 break; | 932 break; |
916 } | 933 } |
917 } | 934 } |
918 | 935 |
919 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() | 936 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1529 json->beginArray(it->key.ascii().data()); | 1546 json->beginArray(it->key.ascii().data()); |
1530 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1547 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1531 json->pushInteger(it->value.ages[age]); | 1548 json->pushInteger(it->value.ages[age]); |
1532 json->endArray(); | 1549 json->endArray(); |
1533 } | 1550 } |
1534 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1551 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
1535 } | 1552 } |
1536 #endif | 1553 #endif |
1537 | 1554 |
1538 } // namespace blink | 1555 } // namespace blink |
OLD | NEW |