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

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

Issue 2406703002: tracing: remove sampling state profiler (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | tools/gn/bootstrap/bootstrap.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 class ParkThreadsScope final { 102 class ParkThreadsScope final {
103 STACK_ALLOCATED(); 103 STACK_ALLOCATED();
104 104
105 public: 105 public:
106 explicit ParkThreadsScope(ThreadState* state) 106 explicit ParkThreadsScope(ThreadState* state)
107 : m_state(state), m_shouldResumeThreads(false) {} 107 : m_state(state), m_shouldResumeThreads(false) {}
108 108
109 bool parkThreads() { 109 bool parkThreads() {
110 TRACE_EVENT0("blink_gc", "ThreadHeap::ParkThreadsScope"); 110 TRACE_EVENT0("blink_gc", "ThreadHeap::ParkThreadsScope");
111 const char* samplingState = TRACE_EVENT_GET_SAMPLING_STATE();
112 if (m_state->isMainThread())
113 TRACE_EVENT_SET_SAMPLING_STATE("blink_gc", "BlinkGCWaiting");
114 111
115 // TODO(haraken): In an unlikely coincidence that two threads decide 112 // TODO(haraken): In an unlikely coincidence that two threads decide
116 // to collect garbage at the same time, avoid doing two GCs in 113 // to collect garbage at the same time, avoid doing two GCs in
117 // a row and return false. 114 // a row and return false.
118 double startTime = WTF::currentTimeMS(); 115 double startTime = WTF::currentTimeMS();
119 116
120 m_shouldResumeThreads = m_state->heap().park(); 117 m_shouldResumeThreads = m_state->heap().park();
121 118
122 double timeForStoppingThreads = WTF::currentTimeMS() - startTime; 119 double timeForStoppingThreads = WTF::currentTimeMS() - startTime;
123 DEFINE_THREAD_SAFE_STATIC_LOCAL( 120 DEFINE_THREAD_SAFE_STATIC_LOCAL(
124 CustomCountHistogram, timeToStopThreadsHistogram, 121 CustomCountHistogram, timeToStopThreadsHistogram,
125 new CustomCountHistogram("BlinkGC.TimeForStoppingThreads", 1, 1000, 122 new CustomCountHistogram("BlinkGC.TimeForStoppingThreads", 1, 1000,
126 50)); 123 50));
127 timeToStopThreadsHistogram.count(timeForStoppingThreads); 124 timeToStopThreadsHistogram.count(timeForStoppingThreads);
128 125
129 if (m_state->isMainThread())
130 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState);
131 return m_shouldResumeThreads; 126 return m_shouldResumeThreads;
132 } 127 }
133 128
134 ~ParkThreadsScope() { 129 ~ParkThreadsScope() {
135 // Only cleanup if we parked all threads in which case the GC happened 130 // Only cleanup if we parked all threads in which case the GC happened
136 // and we need to resume the other threads. 131 // and we need to resume the other threads.
137 if (m_shouldResumeThreads) 132 if (m_shouldResumeThreads)
138 m_state->heap().resume(); 133 m_state->heap().resume();
139 } 134 }
140 135
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 1670
1676 // Try to park the other threads. If we're unable to, bail out of the GC. 1671 // Try to park the other threads. If we're unable to, bail out of the GC.
1677 if (!parkThreadsScope.parkThreads()) 1672 if (!parkThreadsScope.parkThreads())
1678 return; 1673 return;
1679 1674
1680 ScriptForbiddenIfMainThreadScope scriptForbidden; 1675 ScriptForbiddenIfMainThreadScope scriptForbidden;
1681 1676
1682 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping", 1677 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping",
1683 gcType == BlinkGC::GCWithoutSweep, "gcReason", 1678 gcType == BlinkGC::GCWithoutSweep, "gcReason",
1684 gcReasonString(reason)); 1679 gcReasonString(reason));
1685 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC");
1686 double startTime = WTF::currentTimeMS(); 1680 double startTime = WTF::currentTimeMS();
1687 1681
1688 if (gcType == BlinkGC::TakeSnapshot) 1682 if (gcType == BlinkGC::TakeSnapshot)
1689 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); 1683 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC();
1690 1684
1691 // Disallow allocation during garbage collection (but not during the 1685 // Disallow allocation during garbage collection (but not during the
1692 // finalization that happens when the visitorScope is torn down). 1686 // finalization that happens when the visitorScope is torn down).
1693 ThreadState::NoAllocationScope noAllocationScope(this); 1687 ThreadState::NoAllocationScope noAllocationScope(this);
1694 1688
1695 heap().commitCallbackStacks(); 1689 heap().commitCallbackStacks();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, 1812 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep,
1819 BlinkGC::ForcedGC); 1813 BlinkGC::ForcedGC);
1820 size_t liveObjects = heap().heapStats().markedObjectSize(); 1814 size_t liveObjects = heap().heapStats().markedObjectSize();
1821 if (liveObjects == previousLiveObjects) 1815 if (liveObjects == previousLiveObjects)
1822 break; 1816 break;
1823 previousLiveObjects = liveObjects; 1817 previousLiveObjects = liveObjects;
1824 } 1818 }
1825 } 1819 }
1826 1820
1827 } // namespace blink 1821 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | tools/gn/bootstrap/bootstrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698