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_markingTimeInLastGC = 0.0; | |
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_markingTimeInLastGC = 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 ASSERT(ThreadState::current()->isMainThread()); |
2623 return 0.0; | 2627 |
2628 // Marking algorithm takes O(N_live_objs), so the next marking time can be e stimated as: | |
2629 // ~ N_live_objs | |
2630 // t_next = t_last * ------------------ | |
2631 // N_last_live_objs | |
2632 // By estimating N_{,last}_live_objs ratio using object size ratio, we get: | |
2633 // ~ (Size_new_objs + Size_last_marked_objs) * Rate_alive | |
2634 // t_next = t_last * ------------------------------------------------------ | |
2635 // Size_last_marked_objs | |
2636 | |
2637 double estimatedObjectCountIncreaseRatio = 1.0; | |
2638 if (Heap::markedObjectSize() > 0) | |
2639 estimatedObjectCountIncreaseRatio = (Heap::allocatedObjectSize() + Heap: :markedObjectSize()) * ThreadState::current()->collectionRate() / Heap::markedOb jectSize(); | |
2640 | |
2641 return s_markingTimeInLastGC * estimatedObjectCountIncreaseRatio; | |
Sami
2015/03/03 12:25:19
Do you find that this function returns stable valu
rmcilroy
2015/03/03 12:49:13
I would be interested in this too.
| |
2624 } | 2642 } |
2625 | 2643 |
2626 size_t Heap::objectPayloadSizeForTesting() | 2644 size_t Heap::objectPayloadSizeForTesting() |
2627 { | 2645 { |
2628 size_t objectPayloadSize = 0; | 2646 size_t objectPayloadSize = 0; |
2629 for (ThreadState* state : ThreadState::attachedThreads()) { | 2647 for (ThreadState* state : ThreadState::attachedThreads()) { |
2630 state->setGCState(ThreadState::GCRunning); | 2648 state->setGCState(ThreadState::GCRunning); |
2631 state->makeConsistentForSweeping(); | 2649 state->makeConsistentForSweeping(); |
2632 objectPayloadSize += state->objectPayloadSizeForTesting(); | 2650 objectPayloadSize += state->objectPayloadSizeForTesting(); |
2633 state->setGCState(ThreadState::EagerSweepScheduled); | 2651 state->setGCState(ThreadState::EagerSweepScheduled); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2866 FreePagePool* Heap::s_freePagePool; | 2884 FreePagePool* Heap::s_freePagePool; |
2867 OrphanedPagePool* Heap::s_orphanedPagePool; | 2885 OrphanedPagePool* Heap::s_orphanedPagePool; |
2868 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2886 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2869 size_t Heap::s_allocatedObjectSize = 0; | 2887 size_t Heap::s_allocatedObjectSize = 0; |
2870 size_t Heap::s_allocatedSpace = 0; | 2888 size_t Heap::s_allocatedSpace = 0; |
2871 size_t Heap::s_markedObjectSize = 0; | 2889 size_t Heap::s_markedObjectSize = 0; |
2872 | 2890 |
2873 size_t Heap::s_externallyAllocatedBytes = 0; | 2891 size_t Heap::s_externallyAllocatedBytes = 0; |
2874 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2892 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
2875 unsigned Heap::s_requestedUrgentGC = false; | 2893 unsigned Heap::s_requestedUrgentGC = false; |
2894 double Heap::s_markingTimeInLastGC = 0.0; | |
2876 | 2895 |
2877 } // namespace blink | 2896 } // namespace blink |
OLD | NEW |