Implement per activity state CPU usage reporting using diagnostic logging
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 21:33:36 +0000 (21:33 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 21:33:36 +0000 (21:33 +0000)
commita2c82344ba8a56dab5222a4288d932e080e45c86
tree8de9bb468dcd70ac7899d73494430e1827d1e8cd
parent1405bfd449ed81cd1d098da405b526e099ddebb8
Implement per activity state CPU usage reporting using diagnostic logging
https://bugs.webkit.org/show_bug.cgi?id=167163
<rdar://problem/30058349>

Reviewed by Andreas Kling.

Implement per activity state CPU usage reporting using diagnostic logging.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* page/ActivityState.h:
* page/ChromeClient.h:
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::nonVisibleStateKey):
(WebCore::DiagnosticLoggingKeys::visibleNonActiveStateKey):
(WebCore::DiagnosticLoggingKeys::visibleAndActiveStateKey):
(WebCore::DiagnosticLoggingKeys::foregroundCPUUsageToDiagnosticLogginKey):
(WebCore::DiagnosticLoggingKeys::backgroundCPUUsageToDiagnosticLogginKey):
* page/DiagnosticLoggingKeys.h:
* page/Page.cpp:
(WebCore::isUtilityPageChromeClient):
(WebCore::Page::Page):
(WebCore::Page::~Page):
(WebCore::Page::didStartProvisionalLoad):
(WebCore::Page::didFinishLoad):
(WebCore::Page::isUtilityPage):
(WebCore::Page::setActivityState):
(WebCore::Page::setIsVisibleInternal):
* page/Page.h:
(WebCore::Page::activityState):
(WebCore::Page::isUtilityPage):
* page/PerformanceMonitor.cpp: Added.
(WebCore::activityStateForCPUSampling):
(WebCore::PerformanceMonitor::PerformanceMonitor):
(WebCore::PerformanceMonitor::didStartProvisionalLoad):
(WebCore::PerformanceMonitor::didFinishLoad):
(WebCore::PerformanceMonitor::activityStateChanged):
(WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
(WebCore::PerformanceMonitor::measurePostBackgroundingCPUUsage):
(WebCore::PerformanceMonitor::measurePerActivityStateCPUUsage):
(WebCore::stringForCPUSamplingActivityState):
(WebCore::PerformanceMonitor::measureCPUUsageInActivityState):
* page/PerformanceMonitor.h: Copied from Source/WebCore/page/ActivityState.h.
* page/Settings.cpp:
* page/Settings.h:
(WebCore::Settings::isPostLoadCPUUsageMeasurementEnabled):
(WebCore::Settings::isPostBackgroundingCPUUsageMeasurementEnabled):
(WebCore::Settings::isPerActivityStateCPUUsageMeasurementEnabled):

Source/WebKit2:

* Platform/Logging.h:
* UIProcess/PerActivityStateCPUUsageSampler.cpp: Added.
(WebKit::PerActivityStateCPUUsageSampler::PerActivityStateCPUUsageSampler):
(WebKit::PerActivityStateCPUUsageSampler::~PerActivityStateCPUUsageSampler):
(WebKit::PerActivityStateCPUUsageSampler::reportWebContentCPUTime):
(WebKit::loggingKeyForActivityState):
(WebKit::loggingKeyForCPUUsage):
(WebKit::PerActivityStateCPUUsageSampler::loggingTimerFired):
(WebKit::PerActivityStateCPUUsageSampler::pageForLogging):
* UIProcess/PerActivityStateCPUUsageSampler.h: Copied from Source/WebCore/page/ActivityState.h.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool):
(WebKit::WebProcessPool::reportWebContentCPUTime):
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessPool.messages.in:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::reportProcessCPUTime):
* WebProcess/WebCoreSupport/WebChromeClient.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/ActivityState.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PerformanceMonitor.cpp [new file with mode: 0644]
Source/WebCore/page/PerformanceMonitor.h [new file with mode: 0644]
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/Logging.h
Source/WebKit2/UIProcess/PerActivityStateCPUUsageSampler.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/PerActivityStateCPUUsageSampler.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/UIProcess/WebProcessPool.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h