aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.h
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-01-22 10:34:36 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-01-22 10:34:36 +0400
commit98b50b89a8002e1a40f28d1851d0223d424825f6 (patch)
tree112653f6cfbd1bba5d79c5b47d4cf16cae178226 /src/pkg/runtime/runtime.h
parent8a3c587dc1a5f7a9cd87b764b74e28a57935ab40 (diff)
downloadgo-98b50b89a8002e1a40f28d1851d0223d424825f6.tar.xz
runtime: allocate goroutine ids in batches
Helps reduce contention on sched.goidgen. benchmark old ns/op new ns/op delta BenchmarkCreateGoroutines-16 259 237 -8.49% BenchmarkCreateGoroutinesParallel-16 127 43 -66.06% R=golang-codereviews, dave, bradfitz, khr CC=golang-codereviews, rsc https://golang.org/cl/46970043
Diffstat (limited to 'src/pkg/runtime/runtime.h')
-rw-r--r--src/pkg/runtime/runtime.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h
index 119b9e3b7d..5e3c0c497f 100644
--- a/src/pkg/runtime/runtime.h
+++ b/src/pkg/runtime/runtime.h
@@ -385,6 +385,10 @@ struct P
MCache* mcache;
Defer* deferpool[5]; // pool of available Defer structs of different sizes (see panic.c)
+ // Cache of goroutine ids, amortizes accesses to runtime·sched.goidgen.
+ uint64 goidcache;
+ uint64 goidcacheend;
+
// Queue of runnable goroutines.
uint32 runqhead;
uint32 runqtail;