aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-03-29 10:43:31 -0700
committerDmitry Vyukov <dvyukov@google.com>2019-04-09 07:45:26 +0000
commit4166ff42c09cae4ca9e15154627e7cfc80586c65 (patch)
tree135a22462d208dc313e3dd18369ae457362a6786 /src/runtime/export_test.go
parent08e1823a632783e3f71b358f2f546ab0f13a6d98 (diff)
downloadgo-4166ff42c09cae4ca9e15154627e7cfc80586c65.tar.xz
runtime: preempt a goroutine which calls a lot of short system calls
A goroutine should be preempted if it runs for 10ms without blocking. We found that this doesn't work for goroutines which call short system calls. For example, the next program can stuck for seconds without this fix: $ cat main.go package main import ( "runtime" "syscall" ) func main() { runtime.GOMAXPROCS(1) c := make(chan int) go func() { c <- 1 for { t := syscall.Timespec{ Nsec: 300, } if true { syscall.Nanosleep(&t, nil) } } }() <-c } $ time go run main.go real 0m8.796s user 0m0.367s sys 0m0.893s Updates #10958 Change-Id: Id3be54d3779cc28bfc8b33fe578f13778f1ae2a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/170138 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 9eaf92dc7c..a16e664895 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -34,6 +34,8 @@ var Fastlog2 = fastlog2
var Atoi = atoi
var Atoi32 = atoi32
+var Nanotime = nanotime
+
type LFNode struct {
Next uint64
Pushcnt uintptr