Changeset 240522 in webkit
- Timestamp:
- Jan 25, 2019 3:45:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r240521 r240522 1 2019-01-25 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Exclude Debugger Threads from CPU Usage values in Web Inspector 4 https://bugs.webkit.org/show_bug.cgi?id=193796 5 <rdar://problem/47532910> 6 7 Reviewed by Devin Rousso. 8 9 * runtime/SamplingProfiler.cpp: 10 (JSC::SamplingProfiler::machThread): 11 * runtime/SamplingProfiler.h: 12 Expose the mach_port_t of the SamplingProfiler thread 13 so it can be tested against later. 14 1 15 2019-01-25 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
r239427 r240522 1080 1080 } 1081 1081 1082 #if OS(DARWIN) 1083 mach_port_t SamplingProfiler::machThread() 1084 { 1085 if (!m_thread) 1086 return MACH_PORT_NULL; 1087 1088 return m_thread->machThread(); 1089 } 1090 #endif 1091 1082 1092 } // namespace JSC 1083 1093 -
trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h
r239427 r240522 183 183 JS_EXPORT_PRIVATE void reportTopBytecodes(PrintStream&); 184 184 185 #if OS(DARWIN) 186 JS_EXPORT_PRIVATE mach_port_t machThread(); 187 #endif 188 185 189 private: 186 190 void createThreadIfNecessary(const AbstractLocker&); -
trunk/Source/WebCore/ChangeLog
r240519 r240522 1 2019-01-25 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Exclude Debugger Threads from CPU Usage values in Web Inspector 4 https://bugs.webkit.org/show_bug.cgi?id=193796 5 <rdar://problem/47532910> 6 7 Reviewed by Devin Rousso. 8 9 * page/ResourceUsageData.h: 10 * inspector/agents/InspectorCPUProfilerAgent.cpp: 11 (WebCore::InspectorCPUProfilerAgent::collectSample): 12 Show the CPU usage without debugger threads in the Web Inspector's timeline. 13 14 * page/ResourceUsageThread.h: 15 * page/cocoa/ResourceUsageThreadCocoa.mm: 16 (WebCore::ResourceUsageThread::platformSaveStateBeforeStarting): 17 For OS(DARWIN) ports, when starting to observe resource usage, 18 we grab the mach_port_t of SamplingProfiler on the main thread 19 in a thread safe way. For our purposes (Web Inspector timelines), 20 this will be good enough to identify the SamplingProfiler thread 21 during timeline recording. The SamplingProfiler thread won't change 22 during a timeline recording and recording start/stops will never 23 miss the SamplingProfiler changing. 24 25 (WebCore::filterThreads): 26 (WebCore::threadSendRights): 27 (WebCore::threadSendRightsExcludingDebuggerThreads): 28 (WebCore::cpuUsage): 29 (WebCore::ResourceUsageThread::platformCollectCPUData): 30 Calculate CPU usage twice, the second time excluding some threads. 31 32 * page/linux/ResourceUsageThreadLinux.cpp: 33 (WebCore::ResourceUsageThread::platformSaveStateBeforeStarting): 34 (WebCore::ResourceUsageThread::platformCollectCPUData): 35 Stubs for linux ports. 36 1 37 2019-01-25 Zalan Bujtas <zalan@apple.com> 2 38 -
trunk/Source/WebCore/inspector/agents/InspectorCPUProfilerAgent.cpp
r240457 r240522 85 85 auto event = Protocol::CPUProfiler::Event::create() 86 86 .setTimestamp(m_environment.executionStopwatch()->elapsedTimeSince(data.timestamp).seconds()) 87 .setUsage(data.cpu )87 .setUsage(data.cpuExcludingDebuggerThreads) 88 88 .release(); 89 89 -
trunk/Source/WebCore/page/ResourceUsageData.h
r240457 r240522 76 76 77 77 float cpu { 0 }; 78 float cpuExcludingDebuggerThreads { 0 }; 78 79 size_t totalDirtySize { 0 }; 79 80 size_t totalExternalSize { 0 }; -
trunk/Source/WebCore/page/ResourceUsageThread.h
r240457 r240522 38 38 #include <wtf/Threading.h> 39 39 40 #if OS(DARWIN) 41 #include <mach/mach.h> 42 #endif 43 40 44 namespace JSC { 41 45 class VM; … … 71 75 void threadBody(); 72 76 77 void platformSaveStateBeforeStarting(); 73 78 void platformCollectCPUData(JSC::VM*, ResourceUsageData&); 74 79 void platformCollectMemoryData(JSC::VM*, ResourceUsageData&); … … 83 88 // They should ensure their use of the VM is thread safe. 84 89 JSC::VM* m_vm { nullptr }; 90 91 #if ENABLE(SAMPLING_PROFILER) && OS(DARWIN) 92 mach_port_t m_samplingProfilerMachThread { MACH_PORT_NULL }; 93 #endif 94 85 95 }; 86 96 -
trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
r240457 r240522 31 31 #include <JavaScriptCore/GCActivityCallback.h> 32 32 #include <JavaScriptCore/Heap.h> 33 #include <JavaScriptCore/SamplingProfiler.h> 33 34 #include <JavaScriptCore/VM.h> 34 35 #include <mach/mach.h> … … 158 159 } 159 160 160 static float cpuUsage() 161 { 162 auto machThreads = threadSendRights(); 163 161 static float cpuUsage(Vector<MachSendRight>& machThreads) 162 { 164 163 float usage = 0; 165 164 … … 206 205 } 207 206 207 void ResourceUsageThread::platformSaveStateBeforeStarting() 208 { 209 #if ENABLE(SAMPLING_PROFILER) 210 m_samplingProfilerMachThread = m_vm->samplingProfiler() ? m_vm->samplingProfiler()->machThread() : MACH_PORT_NULL; 211 #endif 212 } 213 208 214 void ResourceUsageThread::platformCollectCPUData(JSC::VM*, ResourceUsageData& data) 209 215 { 210 data.cpu = cpuUsage(); 216 Vector<MachSendRight> threads = threadSendRights(); 217 data.cpu = cpuUsage(threads); 218 219 // Remove debugger threads. 220 mach_port_t resourceUsageMachThread = mach_thread_self(); 221 threads.removeAllMatching([&] (MachSendRight& thread) { 222 mach_port_t machThread = thread.sendRight(); 223 if (machThread == resourceUsageMachThread) 224 return true; 225 #if ENABLE(SAMPLING_PROFILER) 226 if (machThread == m_samplingProfilerMachThread) 227 return true; 228 #endif 229 return false; 230 }); 231 232 data.cpuExcludingDebuggerThreads = cpuUsage(threads); 211 233 } 212 234 -
trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp
r240457 r240522 151 151 } 152 152 153 void ResourceUsageThread::platformSaveStateBeforeStarting() 154 { 155 } 156 153 157 void ResourceUsageThread::platformCollectCPUData(JSC::VM*, ResourceUsageData& data) 154 158 { 155 159 data.cpu = cpuUsage(); 160 161 // FIXME: Exclude the ResourceUsage thread. 162 // FIXME: Exclude the SamplingProfiler thread. 163 data.cpuExcludingDebuggerThreads = data.cpu; 156 164 } 157 165
Note: See TracChangeset
for help on using the changeset viewer.