Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: third_party/WebKit/Source/platform/heap/Heap.cpp

Issue 1659053002: Remove custom counts histogram from the blink API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a few thread_safe_static_local -> static_local as per feedback in reviews Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/heap/Heap.h" 31 #include "platform/heap/Heap.h"
32 32
33 #include "platform/Histogram.h"
33 #include "platform/ScriptForbiddenScope.h" 34 #include "platform/ScriptForbiddenScope.h"
34 #include "platform/TraceEvent.h" 35 #include "platform/TraceEvent.h"
35 #include "platform/heap/BlinkGCMemoryDumpProvider.h" 36 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
36 #include "platform/heap/CallbackStack.h" 37 #include "platform/heap/CallbackStack.h"
37 #include "platform/heap/MarkingVisitor.h" 38 #include "platform/heap/MarkingVisitor.h"
38 #include "platform/heap/PageMemory.h" 39 #include "platform/heap/PageMemory.h"
39 #include "platform/heap/PagePool.h" 40 #include "platform/heap/PagePool.h"
40 #include "platform/heap/SafePoint.h" 41 #include "platform/heap/SafePoint.h"
41 #include "platform/heap/ThreadState.h" 42 #include "platform/heap/ThreadState.h"
42 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const char* samplingState = TRACE_EVENT_GET_SAMPLING_STATE(); 105 const char* samplingState = TRACE_EVENT_GET_SAMPLING_STATE();
105 if (m_state->isMainThread()) 106 if (m_state->isMainThread())
106 TRACE_EVENT_SET_SAMPLING_STATE("blink_gc", "BlinkGCWaiting"); 107 TRACE_EVENT_SET_SAMPLING_STATE("blink_gc", "BlinkGCWaiting");
107 108
108 // TODO(haraken): In an unlikely coincidence that two threads decide 109 // TODO(haraken): In an unlikely coincidence that two threads decide
109 // to collect garbage at the same time, avoid doing two GCs in 110 // to collect garbage at the same time, avoid doing two GCs in
110 // a row and return false. 111 // a row and return false.
111 double startTime = WTF::currentTimeMS(); 112 double startTime = WTF::currentTimeMS();
112 bool allParked = gcType != BlinkGC::ThreadTerminationGC && ThreadState:: stopThreads(); 113 bool allParked = gcType != BlinkGC::ThreadTerminationGC && ThreadState:: stopThreads();
113 double timeForStoppingThreads = WTF::currentTimeMS() - startTime; 114 double timeForStoppingThreads = WTF::currentTimeMS() - startTime;
114 Platform::current()->histogramCustomCounts("BlinkGC.TimeForStoppingThrea ds", timeForStoppingThreads, 1, 1000, 50); 115 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, timeToStopThreadsH istogram, new CustomCountHistogram("BlinkGC.TimeForStoppingThreads", 1, 1000, 50 ));
116 timeToStopThreadsHistogram.count(timeForStoppingThreads);
115 117
116 if (m_state->isMainThread()) 118 if (m_state->isMainThread())
117 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); 119 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState);
118 120
119 return allParked; 121 return allParked;
120 } 122 }
121 123
122 Visitor* visitor() const { return m_visitor.get(); } 124 Visitor* visitor() const { return m_visitor.get(); }
123 125
124 private: 126 private:
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // we should have crashed during marking before getting here.) 447 // we should have crashed during marking before getting here.)
446 orphanedPagePool()->decommitOrphanedPages(); 448 orphanedPagePool()->decommitOrphanedPages();
447 449
448 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; 450 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime;
449 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize) : 0; 451 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize) : 0;
450 452
451 #if PRINT_HEAP_STATS 453 #if PRINT_HEAP_STATS
452 dataLogF("Heap::collectGarbage (gcReason=%s, lazySweeping=%d, time=%.1lfms)\ n", gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, markingTimeInMill iseconds); 454 dataLogF("Heap::collectGarbage (gcReason=%s, lazySweeping=%d, time=%.1lfms)\ n", gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, markingTimeInMill iseconds);
453 #endif 455 #endif
454 456
455 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", marking TimeInMilliseconds, 0, 10 * 1000, 50); 457 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, markingTimeHistogram, new CustomCountHistogram("BlinkGC.CollectGarbage", 0, 10 * 1000, 50));
456 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", Heap: :allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); 458 markingTimeHistogram.count(markingTimeInMilliseconds);
457 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace", He ap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); 459 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalObjectSpaceHistog ram, new CustomCountHistogram("BlinkGC.TotalObjectSpace", 0, 4 * 1024 * 1024, 50 ));
460 totalObjectSpaceHistogram.count(Heap::allocatedObjectSize() / 1024);
461 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalAllocatedSpaceHis togram, new CustomCountHistogram("BlinkGC.TotalAllocatedSpace", 0, 4 * 1024 * 10 24, 50));
462 totalAllocatedSpaceHistogram.count(Heap::allocatedSpace() / 1024);
458 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, BlinkG C::NumberOfGCReason); 463 Platform::current()->histogramEnumeration("BlinkGC.GCReason", reason, BlinkG C::NumberOfGCReason);
459 Heap::reportMemoryUsageHistogram(); 464 Heap::reportMemoryUsageHistogram();
460 WTF::Partitions::reportMemoryUsageHistogram(); 465 WTF::Partitions::reportMemoryUsageHistogram();
461 466
462 postGC(gcType); 467 postGC(gcType);
463 468
464 #if ENABLE(ASSERT) 469 #if ENABLE(ASSERT)
465 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n. 470 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n.
466 if (++s_gcGeneration == 0) { 471 if (++s_gcGeneration == 0) {
467 s_gcGeneration = 1; 472 s_gcGeneration = 1;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 double startTime = WTF::currentTimeMS(); 557 double startTime = WTF::currentTimeMS();
553 558
554 // Call weak callbacks on objects that may now be pointing to dead objects. 559 // Call weak callbacks on objects that may now be pointing to dead objects.
555 while (popAndInvokeGlobalWeakCallback(visitor)) { } 560 while (popAndInvokeGlobalWeakCallback(visitor)) { }
556 561
557 // It is not permitted to trace pointers of live objects in the weak 562 // It is not permitted to trace pointers of live objects in the weak
558 // callback phase, so the marking stack should still be empty here. 563 // callback phase, so the marking stack should still be empty here.
559 ASSERT(s_markingStack->isEmpty()); 564 ASSERT(s_markingStack->isEmpty());
560 565
561 double timeForGlobalWeakProcessing = WTF::currentTimeMS() - startTime; 566 double timeForGlobalWeakProcessing = WTF::currentTimeMS() - startTime;
562 Platform::current()->histogramCustomCounts("BlinkGC.TimeForGlobalWeakPrcessi ng", timeForGlobalWeakProcessing, 1, 10 * 1000, 50); 567 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, globalWeakTimeHistogra m, new CustomCountHistogram("BlinkGC.TimeForGlobalWeakPrcessing", 1, 10 * 1000, 50));
568 globalWeakTimeHistogram.count(timeForGlobalWeakProcessing);
563 } 569 }
564 570
565 void Heap::collectAllGarbage() 571 void Heap::collectAllGarbage()
566 { 572 {
567 // We need to run multiple GCs to collect a chain of persistent handles. 573 // We need to run multiple GCs to collect a chain of persistent handles.
568 size_t previousLiveObjects = 0; 574 size_t previousLiveObjects = 0;
569 for (int i = 0; i < 5; ++i) { 575 for (int i = 0; i < 5; ++i) {
570 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); 576 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC);
571 size_t liveObjects = Heap::markedObjectSize(); 577 size_t liveObjects = Heap::markedObjectSize();
572 if (liveObjects == previousLiveObjects) 578 if (liveObjects == previousLiveObjects)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 size_t Heap::s_wrapperCount = 0; 720 size_t Heap::s_wrapperCount = 0;
715 size_t Heap::s_wrapperCountAtLastGC = 0; 721 size_t Heap::s_wrapperCountAtLastGC = 0;
716 size_t Heap::s_collectedWrapperCount = 0; 722 size_t Heap::s_collectedWrapperCount = 0;
717 size_t Heap::s_partitionAllocSizeAtLastGC = 0; 723 size_t Heap::s_partitionAllocSizeAtLastGC = 0;
718 double Heap::s_estimatedMarkingTimePerByte = 0.0; 724 double Heap::s_estimatedMarkingTimePerByte = 0.0;
719 #if ENABLE(ASSERT) 725 #if ENABLE(ASSERT)
720 uint16_t Heap::s_gcGeneration = 0; 726 uint16_t Heap::s_gcGeneration = 0;
721 #endif 727 #endif
722 728
723 } // namespace blink 729 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698