haikuwebkit/Source/WebCore/page/PerformanceMonitor.h

72 lines
2.6 KiB
C
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "ActivityState.h"
#include "Timer.h"
Move WebCore CPUTime to WTF and implement it in all the platforms https://bugs.webkit.org/show_bug.cgi?id=171477 Reviewed by Chris Dumez. Source/WebCore: Move CPUTime to WTF. And rename getCPUTime to CPUTime::get(). * CMakeLists.txt: * PlatformMac.cmake: * WebCore.xcodeproj/project.pbxproj: * page/ChromeClient.h: * page/PerformanceMonitor.cpp: (WebCore::PerformanceMonitor::PerformanceMonitor): (WebCore::PerformanceMonitor::measurePostLoadCPUUsage): (WebCore::PerformanceMonitor::measurePostBackgroundingCPUUsage): (WebCore::PerformanceMonitor::measureCPUUsageInActivityState): * page/PerformanceMonitor.h: * platform/CPUMonitor.cpp: (WebCore::CPUMonitor::setCPULimit): (WebCore::CPUMonitor::timerFired): * platform/CPUMonitor.h: Source/WebKit2: We now hold Seconds in CPUTime instead of int64_t. It finally sends Seconds through WebKit2 IPC. We do not need to specialize ArgumentCoder for Seconds since Seconds just holds double. * UIProcess/PerActivityStateCPUUsageSampler.cpp: (WebKit::PerActivityStateCPUUsageSampler::PerActivityStateCPUUsageSampler): (WebKit::PerActivityStateCPUUsageSampler::reportWebContentCPUTime): (WebKit::PerActivityStateCPUUsageSampler::loggingTimerFired): * UIProcess/PerActivityStateCPUUsageSampler.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::reportWebContentCPUTime): * UIProcess/WebProcessPool.h: * UIProcess/WebProcessPool.messages.in: * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::reportProcessCPUTime): * WebProcess/WebCoreSupport/WebChromeClient.h: Source/WTF: We move WebCore::CPUTime to WTF::CPUTime since it is useful even in JSC and it does not depend on any external libraries. And we additionally implement WTF::CPUTime in all the platforms: Windows and Unix. In CPUTime, instead of holding int64_t, we hold MonotonicTime and Seconds. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CPUTime.cpp: Copied from Source/WebCore/platform/CPUTime.cpp. (WTF::CPUTime::percentageCPUUsageSince): * wtf/CPUTime.h: Renamed from Source/WebCore/platform/CPUTime.h. * wtf/PlatformEfl.cmake: * wtf/PlatformGTK.cmake: * wtf/PlatformJSCOnly.cmake: * wtf/PlatformMac.cmake: * wtf/PlatformWin.cmake: * wtf/cocoa/CPUTimeCocoa.mm: Renamed from Source/WebCore/platform/cocoa/CPUTimeCocoa.mm. (WTF::timeValueToMicroseconds): (WTF::CPUTime::get): * wtf/unix/CPUTimeUnix.cpp: Renamed from Source/WebCore/platform/CPUTime.cpp. (WTF::timevalToSeconds): (WTF::CPUTime::get): * wtf/win/CPUTimeWin.cpp: Added. (WTF::fileTimeToSeconds): (WTF::CPUTime::get): Canonical link: https://commits.webkit.org/188364@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-29 18:03:22 +00:00
#include <wtf/CPUTime.h>
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
namespace WebCore {
class Page;
class PerformanceMonitor {
Mark more heap-allocated classes as fast allocated https://bugs.webkit.org/show_bug.cgi?id=194422 Reviewed by Ryosuke Niwa. Source/WebCore: * Modules/applepay/PaymentCoordinator.h: * Modules/beacon/NavigatorBeacon.h: * Modules/cache/DOMWindowCaches.h: * Modules/cache/WorkerGlobalScopeCaches.h: * Modules/credentialmanagement/NavigatorCredentials.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/gamepad/NavigatorGamepad.h: * Modules/indexeddb/IDBGetAllResult.h: * Modules/indexeddb/IDBGetResult.h: * Modules/indexeddb/IDBKeyData.h: * Modules/indexeddb/IDBValue.h: * Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.h: * Modules/indexeddb/server/IndexValueEntry.h: * Modules/indexeddb/server/IndexValueStore.h: * Modules/indexeddb/server/MemoryBackingStoreTransaction.h: * Modules/indexeddb/server/MemoryCursor.h: * Modules/indexeddb/server/MemoryIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBCursor.h: * Modules/indexeddb/server/SQLiteIDBTransaction.h: * Modules/indexeddb/server/UniqueIDBDatabase.h: * Modules/indexeddb/shared/IDBDatabaseInfo.h: * Modules/indexeddb/shared/IDBResourceIdentifier.h: * Modules/indexeddb/shared/IDBTransactionInfo.h: * Modules/mediacapabilities/NavigatorMediaCapabilities.h: * Modules/mediasession/WebMediaSessionManager.cpp: * Modules/mediastream/NavigatorMediaDevices.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.h: * Modules/navigatorcontentutils/NavigatorContentUtils.h: * Modules/quota/DOMWindowQuota.h: * Modules/quota/NavigatorStorageQuota.h: * Modules/quota/WorkerNavigatorStorageQuota.h: * Modules/speech/DOMWindowSpeechSynthesis.h: * Modules/webaudio/BiquadProcessor.h: * Modules/webaudio/DelayProcessor.h: * Modules/webauthn/fido/FidoHidPacket.h: * Modules/webdriver/NavigatorWebDriver.h: * Modules/webgpu/DOMWindowWebGPU.h: * Modules/websockets/WebSocketChannel.h: * Modules/webvr/NavigatorWebVR.h: * accessibility/AXObjectCache.h: * bindings/js/DOMGCOutputConstraint.h: * bindings/js/DOMPromiseProxy.h: * bridge/c/c_runtime.h: * contentextensions/CombinedURLFilters.cpp: * crypto/CryptoAlgorithmParameters.h: * css/CSSComputedStyleDeclaration.h: * css/CSSRegisteredCustomProperty.h: * css/DOMCSSPaintWorklet.h: * css/DOMCSSRegisterCustomProperty.h: * css/StyleRule.h: * dom/ConstantPropertyMap.h: * dom/CustomElementReactionQueue.h: * dom/Document.h: * dom/GenericEventQueue.h: * dom/RejectedPromiseTracker.h: * dom/UserGestureIndicator.h: * editing/ReplaceSelectionCommand.cpp: * editing/SelectionRectGatherer.h: * editing/TextIterator.h: * editing/cocoa/HTMLConverter.mm: * fileapi/AsyncFileStream.cpp: * fileapi/AsyncFileStream.h: * html/forms/FileIconLoader.h: * html/parser/HTMLTreeBuilder.h: * html/track/WebVTTParser.h: * inspector/DOMPatchSupport.cpp: * loader/FrameLoaderClient.h: * loader/WorkerThreadableLoader.cpp: * page/IntersectionObserver.h: * page/PerformanceMonitor.h: * page/PerformanceUserTiming.h: * page/PrintContext.h: * page/ValidationMessageClient.h: * platform/ColorChooser.h: * platform/ControlStates.h: * platform/DataListSuggestionPicker.h: * platform/FileStream.h: * platform/KeyedCoding.h: * platform/LowPowerModeNotifier.h: * platform/PlatformSpeechSynthesizer.h: * platform/WebGLStateTracker.h: * platform/audio/AudioArray.h: * platform/audio/AudioDestination.h: * platform/audio/DownSampler.h: * platform/audio/DynamicsCompressor.h: * platform/audio/FFTFrame.h: * platform/audio/HRTFDatabase.h: * platform/audio/MultiChannelResampler.h: * platform/audio/Panner.h: * platform/audio/Reverb.h: * platform/audio/ReverbConvolver.h: * platform/audio/ReverbConvolverStage.h: * platform/audio/UpSampler.h: * platform/audio/mac/AudioSessionMac.cpp: * platform/audio/mac/CAAudioStreamDescription.h: * platform/audio/mac/CARingBuffer.h: * platform/cocoa/ScrollSnapAnimatorState.h: * platform/gamepad/PlatformGamepad.h: * platform/graphics/GraphicsLayer.cpp: * platform/graphics/GraphicsLayerFactory.h: * platform/graphics/PlatformTimeRanges.h: * platform/graphics/TextTrackRepresentation.h: * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h: * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h: * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h: * platform/graphics/displaylists/DisplayListRecorder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/sql/SQLiteDatabase.h: * platform/text/TextCodecICU.h: * rendering/GridBaselineAlignment.h: * rendering/GridTrackSizingAlgorithm.h: * rendering/RenderObject.h: * rendering/style/GridArea.h: * workers/service/context/SWContextManager.h: Source/WebCore/PAL: * pal/crypto/openssl/CryptoDigestOpenSSL.cpp: * pal/system/Clock.h: Source/WebKit: * NetworkProcess/NetworkLoad.cpp: * NetworkProcess/NetworkLoadChecker.h: * NetworkProcess/NetworkResourceLoader.cpp: * Platform/IPC/Connection.h: * Platform/IPC/mac/ImportanceAssertion.h: * PluginProcess/PluginCreationParameters.h: * Shared/API/Cocoa/RemoteObjectRegistry.h: * Shared/WebEvent.h: * UIProcess/API/APIHTTPCookieStore.cpp: * UIProcess/API/APINotificationProvider.h: * UIProcess/API/Cocoa/PageLoadStateObserver.h: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setInputDelegate:]): * UIProcess/API/gtk/PageClientImpl.h: * UIProcess/BackingStore.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/ViewGestureController.h: * UIProcess/DeviceIdHashSaltStorage.h: * UIProcess/Downloads/DownloadProxyMap.h: * UIProcess/Gamepad/UIGamepad.h: * UIProcess/Notifications/WebNotificationProvider.h: * UIProcess/ProcessAssertion.h: * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h: * UIProcess/WebContextInjectedBundleClient.h: * UIProcess/WebFormClient.h: * UIProcess/WebGeolocationProvider.h: * UIProcess/WebPageProxy.h: * WebProcess/Automation/WebAutomationSessionProxy.h: * WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageResourceLoadClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h: * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h: * WebProcess/Network/webrtc/LibWebRTCNetwork.h: * WebProcess/Network/webrtc/LibWebRTCSocket.h: * WebProcess/Network/webrtc/WebRTCResolver.h: * WebProcess/WebCoreSupport/WebInspectorClient.cpp: * WebProcess/WebPage/DrawingArea.h: Source/WTF: * wtf/Function.h: (WTF::Function<Out): * wtf/RefCounter.h: * wtf/URL.h: * wtf/text/StringView.cpp: Canonical link: https://commits.webkit.org/208851@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-08 02:38:46 +00:00
WTF_MAKE_FAST_ALLOCATED;
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
public:
explicit PerformanceMonitor(Page&);
void didStartProvisionalLoad();
void didFinishLoad();
Use OptionSet for ActivityState::Flags https://bugs.webkit.org/show_bug.cgi?id=188554 Reviewed by Brent Fulgham. Source/WebCore: More typesafe flags. * Modules/geolocation/GeolocationController.cpp: (WebCore::GeolocationController::activityStateDidChange): * Modules/geolocation/GeolocationController.h: * html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::activityStateDidChange): * html/canvas/WebGLRenderingContextBase.h: * page/ActivityState.cpp: (WebCore::operator<<): (WebCore::activityStateFlagsToString): Deleted. * page/ActivityState.h: (WebCore::ActivityState::allFlags): * page/ActivityStateChangeObserver.h: * page/FocusController.cpp: (WebCore::FocusController::FocusController): (WebCore::FocusController::setFocused): (WebCore::FocusController::setActivityState): (WebCore::FocusController::setActive): * page/FocusController.h: (WebCore::FocusController::isActive const): (WebCore::FocusController::isFocused const): (WebCore::FocusController::contentIsVisible const): * page/Page.cpp: (WebCore::pageInitialActivityState): (WebCore::Page::Page): (WebCore::Page::setIsInWindow): (WebCore::Page::updateTimerThrottlingState): (WebCore::Page::setActivityState): (WebCore::Page::isVisibleAndActive const): (WebCore::Page::isWindowActive const): (WebCore::Page::setIsVisible): * page/Page.h: (WebCore::Page::activityState const): (WebCore::Page::isVisible const): (WebCore::Page::isInWindow const): * page/PerformanceMonitor.cpp: (WebCore::activityStateForCPUSampling): (WebCore::PerformanceMonitor::activityStateChanged): * page/PerformanceMonitor.h: * platform/text/cocoa: Added. Source/WebKit: * Shared/WebPageCreationParameters.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::windowDidOrderOffScreen): (WebKit::WebViewImpl::windowDidOrderOnScreen): (WebKit::WebViewImpl::viewDidMoveToWindow): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::updateActivityState): (WebKit::WebPageProxy::activityStateDidChange): (WebKit::WebPageProxy::dispatchActivityStateChange): (WebKit::WebPageProxy::setMuted): (WebKit::WebPageProxy::isPlayingMediaDidChange): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::isInWindow const): (WebKit::WebPageProxy::isViewVisible const): (WebKit::WebPageProxy::isViewFocused const): (WebKit::WebPageProxy::isViewWindowActive const): * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::activityStateDidChange): * WebProcess/Plugins/PluginView.h: * WebProcess/WebPage/DrawingArea.h: (WebKit::DrawingArea::activityStateDidChange): * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h: * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: (WebKit::RemoteLayerTreeDrawingArea::activityStateDidChange): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updateThrottleState): (WebKit::WebPage::updateIsInWindow): (WebKit::WebPage::visibilityDidChange): (WebKit::WebPage::setActivityState): * WebProcess/WebPage/WebPage.h: (WebKit::WebPage::isVisible const): (WebKit::WebPage::isVisibleOrOccluded const): * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::activityStateDidChange): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::pageActivityStateDidChange): * WebProcess/WebProcess.h: Source/WTF: * wtf/OptionSet.h: (WTF::OptionSet::operator^): Add xor operator, useful for finding changes between sets. Tools: * TestWebKitAPI/Tests/WTF/OptionSet.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/203704@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-16 12:49:01 +00:00
void activityStateChanged(OptionSet<ActivityState::Flag> oldState, OptionSet<ActivityState::Flag> newState);
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
private:
void measurePostLoadCPUUsage();
void measurePostBackgroundingCPUUsage();
void measurePerActivityStateCPUUsage();
void measureCPUUsageInActivityState(ActivityStateForCPUSampling);
void measurePostLoadMemoryUsage();
void measurePostBackgroundingMemoryUsage();
Let MemoryPressureHandler track whether the process is active or inactive. <https://webkit.org/b/169990> Reviewed by Antti Koivisto. Source/WebCore: Have PerformanceMonitor inform MemoryPressureHandler about relevant changes to the page activity states. Also change the "1 hour after last page load" policy to "1 hour after last being visible in an active window." * page/MainFrame.cpp: (WebCore::MainFrame::didCompleteLoad): * page/MainFrame.h: * page/MemoryRelease.cpp: (WebCore::processIsEligibleForMemoryKill): Deleted. * page/MemoryRelease.h: * page/Page.h: (WebCore::Page::performanceMonitor): * page/PerformanceMonitor.cpp: (WebCore::PerformanceMonitor::PerformanceMonitor): (WebCore::PerformanceMonitor::activityStateChanged): (WebCore::PerformanceMonitor::processMayBecomeInactiveTimerFired): (WebCore::PerformanceMonitor::updateProcessStateForMemoryPressure): * page/PerformanceMonitor.h: Source/WebKit2: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeWebProcess): Source/WTF: An active process is a process that meets any of these criteria: - Has had a visible Page in an active window in the last hour - Is playing audio This replaces the old mechanism where MemoryPressureHandler would invoke a callback to know whether the process was eligible for a memory kill. Instead we now plumb the relevant information down from WebCore and kill based on this activity state. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::measurementTimerFired): (WTF::MemoryPressureHandler::setProcessState): * wtf/MemoryPressureHandler.h: (WTF::MemoryPressureHandler::setMemoryKillCallback): (WTF::MemoryPressureHandler::processState): (WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback): Deleted. Canonical link: https://commits.webkit.org/186921@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-23 04:14:03 +00:00
void processMayBecomeInactiveTimerFired();
static void updateProcessStateForMemoryPressure();
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
Page& m_page;
Timer m_postPageLoadCPUUsageTimer;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<CPUTime> m_postLoadCPUTime;
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
Timer m_postBackgroundingCPUUsageTimer;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<CPUTime> m_postBackgroundingCPUTime;
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
Timer m_perActivityStateCPUUsageTimer;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<CPUTime> m_perActivityStateCPUTime;
Timer m_postPageLoadMemoryUsageTimer;
Timer m_postBackgroundingMemoryUsageTimer;
Let MemoryPressureHandler track whether the process is active or inactive. <https://webkit.org/b/169990> Reviewed by Antti Koivisto. Source/WebCore: Have PerformanceMonitor inform MemoryPressureHandler about relevant changes to the page activity states. Also change the "1 hour after last page load" policy to "1 hour after last being visible in an active window." * page/MainFrame.cpp: (WebCore::MainFrame::didCompleteLoad): * page/MainFrame.h: * page/MemoryRelease.cpp: (WebCore::processIsEligibleForMemoryKill): Deleted. * page/MemoryRelease.h: * page/Page.h: (WebCore::Page::performanceMonitor): * page/PerformanceMonitor.cpp: (WebCore::PerformanceMonitor::PerformanceMonitor): (WebCore::PerformanceMonitor::activityStateChanged): (WebCore::PerformanceMonitor::processMayBecomeInactiveTimerFired): (WebCore::PerformanceMonitor::updateProcessStateForMemoryPressure): * page/PerformanceMonitor.h: Source/WebKit2: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeWebProcess): Source/WTF: An active process is a process that meets any of these criteria: - Has had a visible Page in an active window in the last hour - Is playing audio This replaces the old mechanism where MemoryPressureHandler would invoke a callback to know whether the process was eligible for a memory kill. Instead we now plumb the relevant information down from WebCore and kill based on this activity state. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::measurementTimerFired): (WTF::MemoryPressureHandler::setProcessState): * wtf/MemoryPressureHandler.h: (WTF::MemoryPressureHandler::setMemoryKillCallback): (WTF::MemoryPressureHandler::processState): (WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback): Deleted. Canonical link: https://commits.webkit.org/186921@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-23 04:14:03 +00:00
Timer m_processMayBecomeInactiveTimer;
bool m_processMayBecomeInactive { true };
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: Canonical link: https://commits.webkit.org/184264@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210936 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-19 21:33:36 +00:00
};
}