]> Cypherpunks repositories - gostls13.git/commit
runtime: capture runtimeInitTime after nanotime is initialized
authorAustin Clements <austin@google.com>
Thu, 24 Aug 2017 19:06:26 +0000 (15:06 -0400)
committerAustin Clements <austin@google.com>
Fri, 25 Aug 2017 16:02:17 +0000 (16:02 +0000)
commit9d17e175e07a32f919e122faf617e09f9c9726da
treed5f63668194e1d7995f1d06d505b4817314127e9
parent05ff6bfe3367837a8bdf8f72ed5ceaecbbd7b5e8
runtime: capture runtimeInitTime after nanotime is initialized

CL 36428 changed the way nanotime works so on Darwin and Windows it
now depends on runtime.startNano, which is computed at runtime.init
time. Unfortunately, the `runtimeInitTime = nanotime()` initialization
happened *before* runtime.init, so on these platforms runtimeInitTime
is set incorrectly. The one (and only) consequence of this is that the
start time printed in gctrace lines is bogus:

gc 1 18446653480.186s 0%: 0.092+0.47+0.038 ms clock, 0.37+0.15/0.81/1.8+0.15 ms cpu, 4->4->1 MB, 5 MB goal, 8 P

To fix this, this commit moves the runtimeInitTime initialization to
shortly after runtime.init, at which point nanotime is safe to use.

This also requires changing the condition in newproc1 that currently
uses runtimeInitTime != 0 simply to detect whether or not the main M
has started. Since runtimeInitTime could genuinely be 0 now, this
introduces a separate flag to newproc1.

Fixes #21554.

Change-Id: Id874a4b912d3fa3d22f58d01b31ffb3548266d3b
Reviewed-on: https://go-review.googlesource.com/58690
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/proc.go