Commit e8923087 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Add option to raise timer interrupt frequency for all Chrome processes

Chrome's handling of latency sensitive tasks such as video playback can
easily be affected by the frequency of the Windows timer interrupt. This
timer interrupt is a global resource and any process can raise its
frequency. Previously this would affect thread scheduling for all
processes but with Windows 10 2004 Microsoft appears to try to simulate
"normal" thread scheduling in processes that did not themselves alter
the timer interrupt frequency.

This is suspected of causing frame drops during video playback. The
easiest way to rule out this as the cause is to get all Chrome processes
to raise the timer interrupt frequency to the maximum level so that they
will all get scheduled according to that raised frequency.

This flag should not be generally used and may be removed in the future.

Bug: 1128917
Change-Id: I97fddebab251240fdb6181d6960b0dea86b9f0b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2458854
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815530}
parent b16024e3
......@@ -23,6 +23,9 @@
#endif
#if defined(OS_WIN)
#include <timeapi.h>
#include "base/base_switches.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_functions.h"
......@@ -97,6 +100,14 @@ int ChromeMain(int argc, const char** argv) {
const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
ALLOW_UNUSED_LOCAL(command_line);
#if defined(OS_WIN)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kRaiseTimerFrequency)) {
// Raise the timer interrupt frequency and leave it raised.
timeBeginPeriod(1);
}
#endif
#if defined(OS_MAC)
SetUpBundleOverrides();
#endif
......
......@@ -328,6 +328,7 @@ bool ServiceUtilityProcessHost::Launch(base::CommandLine* cmd_line,
switches::kVModule,
#if defined(OS_WIN)
switches::kDisableHighResTimer,
switches::kRaiseTimerFrequency,
#endif
};
cmd_line->CopySwitchesFrom(service_command_line, kForwardSwitches,
......
......@@ -32,6 +32,7 @@ void CopyNaClCommandLineArguments(base::CommandLine* cmd_line) {
#endif
#if defined(OS_WIN)
switches::kDisableHighResTimer,
switches::kRaiseTimerFrequency,
#endif
};
cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
......
......@@ -231,6 +231,7 @@ static const char* const kSwitchNames[] = {
#endif
#if defined(OS_WIN)
switches::kDisableHighResTimer,
switches::kRaiseTimerFrequency,
#endif // defined(OS_WIN)
switches::kEnableANGLEFeatures,
switches::kDisableANGLEFeatures,
......
......@@ -3476,6 +3476,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kDisableHighResTimer,
switches::kEnableWin7WebRtcHWH264Decoding,
switches::kTrySupportedChannelLayouts,
switches::kRaiseTimerFrequency,
#endif
#if defined(USE_OZONE)
switches::kOzonePlatform,
......
......@@ -281,6 +281,7 @@ bool UtilityProcessHost::StartProcess() {
switches::kDisableHighResTimer,
switches::kEnableExclusiveAudio,
switches::kForceWaveAudio,
switches::kRaiseTimerFrequency,
switches::kTrySupportedChannelLayouts,
switches::kWaveOutBuffers,
switches::kWebXrForceRuntime,
......
......@@ -1026,6 +1026,12 @@ const char kPpapiAntialiasedTextEnabled[] = "ppapi-antialiased-text-enabled";
const char kPpapiSubpixelRenderingSetting[] =
"ppapi-subpixel-rendering-setting";
// Raise the timer interrupt frequency in all Chrome processes, for experimental
// purposes. This feature is needed because as of Windows 10 2004 the scheduling
// effects of changing the timer interrupt frequency are not global, and this
// lets us prove/disprove whether this matters. See https://crbug.com/1128917
const char kRaiseTimerFrequency[] = "raise-timer-frequency";
// Causes the second GPU process used for gpu info collection to display a
// dialog on launch.
const char kGpu2StartupDialog[] = "gpu2-startup-dialog";
......
......@@ -288,6 +288,7 @@ CONTENT_EXPORT extern const char kEnableWin7WebRtcHWH264Decoding[];
CONTENT_EXPORT extern const char kFontCacheSharedHandle[];
CONTENT_EXPORT extern const char kPpapiAntialiasedTextEnabled[];
CONTENT_EXPORT extern const char kPpapiSubpixelRenderingSetting[];
CONTENT_EXPORT extern const char kRaiseTimerFrequency[];
CONTENT_EXPORT extern const char kGpu2StartupDialog[];
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment