]> Cypherpunks repositories - gostls13.git/commit
runtime: reduce Windows timer resolution when idle
authorAustin Clements <austin@google.com>
Tue, 21 Mar 2017 20:45:12 +0000 (16:45 -0400)
committerAustin Clements <austin@google.com>
Sat, 29 Apr 2017 04:15:49 +0000 (04:15 +0000)
commit11eaf428867417b9d5fab4deadd0ef03c9fd9773
treeb81e73be39f7a17f61cafbbfd1d873d68130183f
parentb225396f935737cbd64164b67aeb8f1bb8ac08be
runtime: reduce Windows timer resolution when idle

Currently Go sets the system-wide timer resolution to 1ms the whole
time it's running. This has negative affects on system performance and
power consumption. Unfortunately, simply reducing the timer resolution
to the default 15ms interferes with several sleeps in the runtime
itself, including sysmon's ability to interrupt goroutines.

This commit takes a hybrid approach: it only reduces the timer
resolution when the Go process is entirely idle. When the process is
idle, nothing needs a high resolution timer. When the process is
non-idle, it's already consuming CPU so it doesn't really matter if
the OS also takes timer interrupts more frequently.

Updates #8687.

Change-Id: I0652564b4a36d61a80e045040094a39c19da3b06
Reviewed-on: https://go-review.googlesource.com/38403
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/os_windows.go
src/runtime/proc.go
src/runtime/relax_stub.go [new file with mode: 0644]