]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: do not call timeBeginPeriod on windows
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 23 Nov 2015 04:26:00 +0000 (15:26 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Tue, 24 Nov 2015 01:11:58 +0000 (01:11 +0000)
Calling timeBeginPeriod changes Windows global timer resolution
from 15ms to 1ms. This used to improve Go runtime scheduler
performance, but not anymore. Thanks to @aclements, scheduler now
behaves the same way if we call timeBeginPeriod or not.

Remove call to timeBeginPeriod, since it is machine global
resource, and there are downsides of using low timer resolution.
See issue #8687 for details.

Fixes #8687

Change-Id: Ib7e41aa4a81861b62a900e0e62776c9ef19bfb73
Reviewed-on: https://go-review.googlesource.com/17164
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>

src/runtime/export_windows_test.go
src/runtime/os1_windows.go
src/runtime/syscall_windows_test.go

index 703b422ac2315abc50a33c46dc1059a892e90cc9..f712c6f65353c60df57708949c369f7399055ab4 100644 (file)
@@ -8,10 +8,7 @@ package runtime
 
 import "unsafe"
 
-var (
-       TestingWER              = &testingWER
-       TimeBeginPeriodRetValue = &timeBeginPeriodRetValue
-)
+var TestingWER = &testingWER
 
 func NumberOfProcessors() int32 {
        var info systeminfo
index 551705797d935b51bace25669c274d7745a642f1..90e03674a406915401bc987461ab99c961e7abcb 100644 (file)
@@ -47,7 +47,6 @@ import (
 //go:cgo_import_dynamic runtime._WaitForSingleObject WaitForSingleObject%2 "kernel32.dll"
 //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll"
 //go:cgo_import_dynamic runtime._WriteFile WriteFile%5 "kernel32.dll"
-//go:cgo_import_dynamic runtime._timeBeginPeriod timeBeginPeriod%1 "winmm.dll"
 
 var (
        // Following syscalls are available on every Windows PC.
@@ -90,8 +89,7 @@ var (
        _WSAGetOverlappedResult,
        _WaitForSingleObject,
        _WriteConsoleW,
-       _WriteFile,
-       _timeBeginPeriod stdFunction
+       _WriteFile stdFunction
 
        // Following syscalls are only available on some Windows PCs.
        // We will load syscalls, if available, before using them.
@@ -161,8 +159,6 @@ const (
 // in sys_windows_386.s and sys_windows_amd64.s
 func externalthreadhandler()
 
-var timeBeginPeriodRetValue uint32
-
 func osinit() {
        asmstdcallAddr = unsafe.Pointer(funcPC(asmstdcall))
 
@@ -178,8 +174,6 @@ func osinit() {
 
        stdcall2(_SetConsoleCtrlHandler, funcPC(ctrlhandler), 1)
 
-       timeBeginPeriodRetValue = uint32(stdcall1(_timeBeginPeriod, 1))
-
        ncpu = getproccount()
 
        // Windows dynamic priority boosting assumes that a process has different types
index 8b9945b22ddfdf64c7e21baae7ad3c28cda1aab6..30630bc904fcf48edbe88adf5a434868e3ca9d96 100644 (file)
@@ -642,13 +642,6 @@ uintptr_t cfunc(callback f, uintptr_t n) {
        }
 }
 
-func TestTimeBeginPeriod(t *testing.T) {
-       const TIMERR_NOERROR = 0
-       if *runtime.TimeBeginPeriodRetValue != TIMERR_NOERROR {
-               t.Fatalf("timeBeginPeriod failed: it returned %d", *runtime.TimeBeginPeriodRetValue)
-       }
-}
-
 // removeOneCPU removes one (any) cpu from affinity mask.
 // It returns new affinity mask.
 func removeOneCPU(mask uintptr) (uintptr, error) {