Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move PerformanceMonitor related DeprecatedGlobalSettings to Settings
https://bugs.webkit.org/show_bug.cgi?id=215963

Reviewed by Anders Carlsson.

The PerformanceMonitor related uses of DeprecatedGlobalSettings can easily be moved to Settings, as PerformanceMonitor
has a Page reference.

* page/DeprecatedGlobalSettings.h:
(WebCore::DeprecatedGlobalSettings::isPostLoadCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostBackgroundingCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostLoadMemoryUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostBackgroundingMemoryUsageMeasurementEnabled): Deleted.
* page/Settings.yaml:
* page/SettingsDefaultValues.h:
Moved settings from DeprecatedGlobalSettings.h to Settings.yaml. Default values encoded in SettingsDefaultValues.h

* page/PerformanceMonitor.cpp:
(WebCore::PerformanceMonitor::PerformanceMonitor):
(WebCore::PerformanceMonitor::didFinishLoad):
(WebCore::PerformanceMonitor::activityStateChanged):
Access the settings via m_page.settings(). Update constants to use constexpr.


Canonical link: https://commits.webkit.org/228764@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266328 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Aug 30, 2020
1 parent d116fc7 commit 63b8636
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 68 deletions.
26 changes: 26 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,29 @@
2020-08-29 Sam Weinig <weinig@apple.com>

Move PerformanceMonitor related DeprecatedGlobalSettings to Settings
https://bugs.webkit.org/show_bug.cgi?id=215963

Reviewed by Anders Carlsson.

The PerformanceMonitor related uses of DeprecatedGlobalSettings can easily be moved to Settings, as PerformanceMonitor
has a Page reference.

* page/DeprecatedGlobalSettings.h:
(WebCore::DeprecatedGlobalSettings::isPostLoadCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostBackgroundingCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostLoadMemoryUsageMeasurementEnabled): Deleted.
(WebCore::DeprecatedGlobalSettings::isPostBackgroundingMemoryUsageMeasurementEnabled): Deleted.
* page/Settings.yaml:
* page/SettingsDefaultValues.h:
Moved settings from DeprecatedGlobalSettings.h to Settings.yaml. Default values encoded in SettingsDefaultValues.h

* page/PerformanceMonitor.cpp:
(WebCore::PerformanceMonitor::PerformanceMonitor):
(WebCore::PerformanceMonitor::didFinishLoad):
(WebCore::PerformanceMonitor::activityStateChanged):
Access the settings via m_page.settings(). Update constants to use constexpr.

2020-08-28 Chris Dumez <cdumez@apple.com>

Update PannerNode to support k-rate automation of its AudioParams
Expand Down
52 changes: 0 additions & 52 deletions Source/WebCore/page/DeprecatedGlobalSettings.h
Expand Up @@ -39,13 +39,6 @@ class DeprecatedGlobalSettings {
static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; }
#endif

static bool isPostLoadCPUUsageMeasurementEnabled();
static bool isPostBackgroundingCPUUsageMeasurementEnabled();
static bool isPerActivityStateCPUUsageMeasurementEnabled();

static bool isPostLoadMemoryUsageMeasurementEnabled();
static bool isPostBackgroundingMemoryUsageMeasurementEnabled();

static bool globalConstRedeclarationShouldThrow();

#if USE(AVFOUNDATION)
Expand Down Expand Up @@ -138,49 +131,4 @@ class DeprecatedGlobalSettings {
static bool gAllowsAnySSLCertificate;
};

inline bool DeprecatedGlobalSettings::isPostLoadCPUUsageMeasurementEnabled()
{
#if PLATFORM(COCOA)
return true;
#else
return false;
#endif
}

inline bool DeprecatedGlobalSettings::isPostBackgroundingCPUUsageMeasurementEnabled()
{
#if PLATFORM(MAC)
return true;
#else
return false;
#endif
}

inline bool DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled()
{
#if PLATFORM(MAC)
return true;
#else
return false;
#endif
}

inline bool DeprecatedGlobalSettings::isPostLoadMemoryUsageMeasurementEnabled()
{
#if PLATFORM(COCOA)
return true;
#else
return false;
#endif
}

inline bool DeprecatedGlobalSettings::isPostBackgroundingMemoryUsageMeasurementEnabled()
{
#if PLATFORM(MAC)
return true;
#else
return false;
#endif
}

} // namespace WebCore
30 changes: 15 additions & 15 deletions Source/WebCore/page/PerformanceMonitor.cpp
Expand Up @@ -28,31 +28,31 @@

#include "Chrome.h"
#include "ChromeClient.h"
#include "DeprecatedGlobalSettings.h"
#include "DiagnosticLoggingClient.h"
#include "DiagnosticLoggingKeys.h"
#include "Frame.h"
#include "Logging.h"
#include "Page.h"
#include "PerformanceLogging.h"
#include "RegistrableDomain.h"
#include "Settings.h"

namespace WebCore {

#define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - PerformanceMonitor::" fmt, this, ##__VA_ARGS__)

static const Seconds cpuUsageMeasurementDelay { 5_s };
static const Seconds postLoadCPUUsageMeasurementDuration { 10_s };
static const Seconds backgroundCPUUsageMeasurementDuration { 5_min };
static const Seconds cpuUsageSamplingInterval { 10_min };
static constexpr const Seconds cpuUsageMeasurementDelay { 5_s };
static constexpr const Seconds postLoadCPUUsageMeasurementDuration { 10_s };
static constexpr const Seconds backgroundCPUUsageMeasurementDuration { 5_min };
static constexpr const Seconds cpuUsageSamplingInterval { 10_min };

static const Seconds memoryUsageMeasurementDelay { 10_s };
static constexpr const Seconds memoryUsageMeasurementDelay { 10_s };

static const Seconds delayBeforeProcessMayBecomeInactive { 8_min };
static constexpr const Seconds delayBeforeProcessMayBecomeInactive { 8_min };

static const double postPageLoadCPUUsageDomainReportingThreshold { 20.0 }; // Reporting pages using over 20% CPU is roughly equivalent to reporting the 10% worst pages.
static constexpr const double postPageLoadCPUUsageDomainReportingThreshold { 20.0 }; // Reporting pages using over 20% CPU is roughly equivalent to reporting the 10% worst pages.
#if !PLATFORM(IOS_FAMILY)
static const uint64_t postPageLoadMemoryUsageDomainReportingThreshold { 2048 * MB };
static constexpr const uint64_t postPageLoadMemoryUsageDomainReportingThreshold { 2048 * MB };
#endif

static inline ActivityStateForCPUSampling activityStateForCPUSampling(OptionSet<ActivityState::Flag> state)
Expand All @@ -75,7 +75,7 @@ PerformanceMonitor::PerformanceMonitor(Page& page)
{
ASSERT(!page.isUtilityPage());

if (DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled()) {
if (page.settings().isPerActivityStateCPUUsageMeasurementEnabled()) {
m_perActivityStateCPUTime = CPUTime::get();
m_perActivityStateCPUUsageTimer.startRepeating(cpuUsageSamplingInterval);
}
Expand All @@ -91,13 +91,13 @@ void PerformanceMonitor::didStartProvisionalLoad()
void PerformanceMonitor::didFinishLoad()
{
// Only do post-load CPU usage measurement if there is a single Page in the process in order to reduce noise.
if (DeprecatedGlobalSettings::isPostLoadCPUUsageMeasurementEnabled() && m_page.isOnlyNonUtilityPage()) {
if (m_page.settings().isPostLoadCPUUsageMeasurementEnabled() && m_page.isOnlyNonUtilityPage()) {
m_postLoadCPUTime = WTF::nullopt;
m_postPageLoadCPUUsageTimer.startOneShot(cpuUsageMeasurementDelay);
}

// Likewise for post-load memory usage measurement.
if (DeprecatedGlobalSettings::isPostLoadMemoryUsageMeasurementEnabled() && m_page.isOnlyNonUtilityPage())
if (m_page.settings().isPostLoadMemoryUsageMeasurementEnabled() && m_page.isOnlyNonUtilityPage())
m_postPageLoadMemoryUsageTimer.startOneShot(memoryUsageMeasurementDelay);
}

Expand All @@ -107,15 +107,15 @@ void PerformanceMonitor::activityStateChanged(OptionSet<ActivityState::Flag> old
bool visibilityChanged = changed.contains(ActivityState::IsVisible);

// Measure CPU usage of pages when they are no longer visible.
if (DeprecatedGlobalSettings::isPostBackgroundingCPUUsageMeasurementEnabled() && visibilityChanged) {
if (m_page.settings().isPostBackgroundingCPUUsageMeasurementEnabled() && visibilityChanged) {
m_postBackgroundingCPUTime = WTF::nullopt;
if (newState & ActivityState::IsVisible)
m_postBackgroundingCPUUsageTimer.stop();
else if (m_page.isOnlyNonUtilityPage())
m_postBackgroundingCPUUsageTimer.startOneShot(cpuUsageMeasurementDelay);
}

if (DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled()) {
if (m_page.settings().isPerActivityStateCPUUsageMeasurementEnabled()) {
// If visibility changed then report CPU usage right away because CPU usage is connected to visibility state.
auto oldActivityStateForCPUSampling = activityStateForCPUSampling(oldState);
if (oldActivityStateForCPUSampling != activityStateForCPUSampling(newState)) {
Expand All @@ -124,7 +124,7 @@ void PerformanceMonitor::activityStateChanged(OptionSet<ActivityState::Flag> old
}
}

if (DeprecatedGlobalSettings::isPostBackgroundingMemoryUsageMeasurementEnabled() && visibilityChanged) {
if (m_page.settings().isPostBackgroundingMemoryUsageMeasurementEnabled() && visibilityChanged) {
if (newState & ActivityState::IsVisible)
m_postBackgroundingMemoryUsageTimer.stop();
else if (m_page.isOnlyNonUtilityPage())
Expand Down
18 changes: 17 additions & 1 deletion Source/WebCore/page/Settings.yaml
Expand Up @@ -983,6 +983,21 @@ dateTimeInputsEditableComponentsEnabled:
initial: false
conditional: DATE_AND_TIME_INPUT_TYPES

isPostLoadCPUUsageMeasurementEnabled:
initial: defaultPostLoadCPUUsageMeasurementEnabled

isPostLoadMemoryUsageMeasurementEnabled:
initial: defaultPostLoadMemoryUsageMeasurementEnabled

isPostBackgroundingCPUUsageMeasurementEnabled:
initial: defaultPostBackgroundingCPUUsageMeasurementEnabled

isPostBackgroundingMemoryUsageMeasurementEnabled:
initial: defaultPostBackgroundingMemoryUsageMeasurementEnabled

isPerActivityStateCPUUsageMeasurementEnabled:
initial: defaultPerActivityStateCPUUsageMeasurementEnabled

# Deprecated

iceCandidateFilteringEnabled:
Expand All @@ -1006,4 +1021,5 @@ shouldUseServiceWorkerShortTimeout:

# Clients should use per-navigation "allowsContentJavaScript" policies instead
scriptMarkupEnabled:
initial: true
initial: true

19 changes: 19 additions & 0 deletions Source/WebCore/page/SettingsDefaultValues.h
Expand Up @@ -118,4 +118,23 @@ static const bool defaultApplePayEnabled = true;
static const bool defaultApplePayEnabled = false;
#endif


#if PLATFORM(COCOA)
static constexpr const bool defaultPostLoadCPUUsageMeasurementEnabled = true;
static constexpr const bool defaultPostLoadMemoryUsageMeasurementEnabled = true;
#else
static constexpr const bool defaultPostLoadCPUUsageMeasurementEnabled = false;
static constexpr const bool defaultPostLoadMemoryUsageMeasurementEnabled = false;
#endif

#if PLATFORM(MAC)
static constexpr const bool defaultPostBackgroundingCPUUsageMeasurementEnabled = true;
static constexpr const bool defaultPerActivityStateCPUUsageMeasurementEnabled = true;
static constexpr const bool defaultPostBackgroundingMemoryUsageMeasurementEnabled = true;
#else
static constexpr const bool defaultPostBackgroundingCPUUsageMeasurementEnabled = false;
static constexpr const bool defaultPerActivityStateCPUUsageMeasurementEnabled = false;
static constexpr const bool defaultPostBackgroundingMemoryUsageMeasurementEnabled = false;
#endif

}

0 comments on commit 63b8636

Please sign in to comment.