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 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2194 s_postMarkingCallbackStack = new CallbackStack(); | 2194 s_postMarkingCallbackStack = new CallbackStack(); |
| 2195 s_weakCallbackStack = new CallbackStack(); | 2195 s_weakCallbackStack = new CallbackStack(); |
| 2196 s_ephemeronStack = new CallbackStack(); | 2196 s_ephemeronStack = new CallbackStack(); |
| 2197 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 2197 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
| 2198 s_markingVisitor = new MarkingVisitor<GlobalMarking>(); | 2198 s_markingVisitor = new MarkingVisitor<GlobalMarking>(); |
| 2199 s_freePagePool = new FreePagePool(); | 2199 s_freePagePool = new FreePagePool(); |
| 2200 s_orphanedPagePool = new OrphanedPagePool(); | 2200 s_orphanedPagePool = new OrphanedPagePool(); |
| 2201 s_allocatedObjectSize = 0; | 2201 s_allocatedObjectSize = 0; |
| 2202 s_allocatedSpace = 0; | 2202 s_allocatedSpace = 0; |
| 2203 s_markedObjectSize = 0; | 2203 s_markedObjectSize = 0; |
| 2204 s_recentMarkingTime = 0.0; | |
|
haraken
2015/03/02 04:49:41
s_recentMarkingTime => s_markingTimeInLastGC
kouhei (in TOK)
2015/03/03 04:45:08
Done.
| |
| 2204 | 2205 |
| 2205 GCInfoTable::init(); | 2206 GCInfoTable::init(); |
| 2206 } | 2207 } |
| 2207 | 2208 |
| 2208 void Heap::shutdown() | 2209 void Heap::shutdown() |
| 2209 { | 2210 { |
| 2210 s_shutdownCalled = true; | 2211 s_shutdownCalled = true; |
| 2211 ThreadState::shutdownHeapIfNecessary(); | 2212 ThreadState::shutdownHeapIfNecessary(); |
| 2212 } | 2213 } |
| 2213 | 2214 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2501 // pointers to the orphaned pages. (If we have such dangling pointers, | 2502 // pointers to the orphaned pages. (If we have such dangling pointers, |
| 2502 // we should have crashed during marking before getting here.) | 2503 // we should have crashed during marking before getting here.) |
| 2503 orphanedPagePool()->decommitOrphanedPages(); | 2504 orphanedPagePool()->decommitOrphanedPages(); |
| 2504 | 2505 |
| 2505 postGC(gcType); | 2506 postGC(gcType); |
| 2506 | 2507 |
| 2507 #if ENABLE(GC_PROFILING) | 2508 #if ENABLE(GC_PROFILING) |
| 2508 static_cast<MarkingVisitor<GlobalMarking>*>(s_markingVisitor)->reportStats() ; | 2509 static_cast<MarkingVisitor<GlobalMarking>*>(s_markingVisitor)->reportStats() ; |
| 2509 #endif | 2510 #endif |
| 2510 | 2511 |
| 2512 double markingTimeInMilliseconds = WTF::currentTimeMS() - timeStamp; | |
| 2513 s_recentMarkingTime = markingTimeInMilliseconds / 1000; | |
| 2514 | |
| 2511 if (Platform::current()) { | 2515 if (Platform::current()) { |
| 2512 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF ::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); | 2516 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", mar kingTimeInMilliseconds, 0, 10 * 1000, 50); |
| 2513 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); | 2517 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); |
| 2514 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace" , Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); | 2518 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace" , Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); |
| 2515 } | 2519 } |
| 2516 | 2520 |
| 2517 if (state->isMainThread()) | 2521 if (state->isMainThread()) |
| 2518 ScriptForbiddenScope::exit(); | 2522 ScriptForbiddenScope::exit(); |
| 2519 } | 2523 } |
| 2520 | 2524 |
| 2521 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2525 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
| 2522 { | 2526 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2612 // should die. Unfortunately it is not the case for all objects | 2616 // should die. Unfortunately it is not the case for all objects |
| 2613 // because the hierarchy was not completely moved to the heap and | 2617 // because the hierarchy was not completely moved to the heap and |
| 2614 // some heap allocated objects own objects that contain persistents | 2618 // some heap allocated objects own objects that contain persistents |
| 2615 // pointing to other heap allocated objects. | 2619 // pointing to other heap allocated objects. |
| 2616 for (int i = 0; i < 5; ++i) | 2620 for (int i = 0; i < 5; ++i) |
| 2617 collectGarbage(ThreadState::NoHeapPointersOnStack); | 2621 collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 2618 } | 2622 } |
| 2619 | 2623 |
| 2620 double Heap::estimatedMarkingTime() | 2624 double Heap::estimatedMarkingTime() |
| 2621 { | 2625 { |
| 2622 // FIXME: Implement heuristics | 2626 // Marking algorithm takes O(N_live_objs), so the next marking time can be e stimated as: |
| 2623 return 0.0; | 2627 // ~ N_live_objs |
| 2628 // t_next = t_last * ------------------ | |
| 2629 // N_last_live_objs | |
| 2630 // By estimating N_{,last}_live_objs ratio using object size ratio, we get: | |
| 2631 // ~ (Size_new_objs + Size_last_marked_objs) * Rate_alive | |
| 2632 // t_next = t_last * ------------------------------------------------------ | |
| 2633 // Size_last_marked_objs | |
| 2634 | |
| 2635 double estimatedObjectCountIncreaseRatio = 1.0; | |
| 2636 if (Heap::markedObjectSize() > 0) | |
| 2637 estimatedObjectCountIncreaseRatio = (Heap::allocatedObjectSize() + Heap: :markedObjectSize()) * ThreadState::mainThreadState()->collectionRate() / Heap:: markedObjectSize(); | |
|
haraken
2015/03/02 04:49:41
Can you fprintf estimatedObjectCountIncreaseRatio
haraken
2015/03/02 04:49:41
I'd prefer to add ASSERT(isMainThread()) at the to
kouhei (in TOK)
2015/03/03 04:45:08
Tested locally visiting some real world websites.
kouhei (in TOK)
2015/03/03 04:45:08
Done.
| |
| 2638 | |
| 2639 return s_recentMarkingTime * estimatedObjectCountIncreaseRatio; | |
| 2624 } | 2640 } |
| 2625 | 2641 |
| 2626 size_t Heap::objectPayloadSizeForTesting() | 2642 size_t Heap::objectPayloadSizeForTesting() |
| 2627 { | 2643 { |
| 2628 size_t objectPayloadSize = 0; | 2644 size_t objectPayloadSize = 0; |
| 2629 for (ThreadState* state : ThreadState::attachedThreads()) { | 2645 for (ThreadState* state : ThreadState::attachedThreads()) { |
| 2630 state->setGCState(ThreadState::GCRunning); | 2646 state->setGCState(ThreadState::GCRunning); |
| 2631 state->makeConsistentForSweeping(); | 2647 state->makeConsistentForSweeping(); |
| 2632 objectPayloadSize += state->objectPayloadSizeForTesting(); | 2648 objectPayloadSize += state->objectPayloadSizeForTesting(); |
| 2633 state->setGCState(ThreadState::EagerSweepScheduled); | 2649 state->setGCState(ThreadState::EagerSweepScheduled); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2876 FreePagePool* Heap::s_freePagePool; | 2892 FreePagePool* Heap::s_freePagePool; |
| 2877 OrphanedPagePool* Heap::s_orphanedPagePool; | 2893 OrphanedPagePool* Heap::s_orphanedPagePool; |
| 2878 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2894 Heap::RegionTree* Heap::s_regionTree = nullptr; |
| 2879 size_t Heap::s_allocatedObjectSize = 0; | 2895 size_t Heap::s_allocatedObjectSize = 0; |
| 2880 size_t Heap::s_allocatedSpace = 0; | 2896 size_t Heap::s_allocatedSpace = 0; |
| 2881 size_t Heap::s_markedObjectSize = 0; | 2897 size_t Heap::s_markedObjectSize = 0; |
| 2882 | 2898 |
| 2883 size_t Heap::s_externallyAllocatedBytes = 0; | 2899 size_t Heap::s_externallyAllocatedBytes = 0; |
| 2884 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2900 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
| 2885 unsigned Heap::s_requestedUrgentGC = false; | 2901 unsigned Heap::s_requestedUrgentGC = false; |
| 2902 double Heap::s_recentMarkingTime = 0.0; | |
| 2886 | 2903 |
| 2887 } // namespace blink | 2904 } // namespace blink |
| OLD | NEW |