1
0
mirror of https://github.com/golang/go synced 2024-11-11 17:51:49 -07:00

runtime: fix trace.Stop run indefinitely when built with faketime

Updated doc for the logic

Change-Id: I8b4df301b925ddea648bbb49bc35bc718046bd59
This commit is contained in:
Hiro 2023-06-16 08:23:04 +05:30
parent 9ece9a7ac9
commit d300ca3f31

View File

@ -453,12 +453,17 @@ func StopTrace() {
}
}
// Wait for startNanotime != endNanotime. On Windows the default interval between
// system clock ticks is typically between 1 and 15 milliseconds, which may not
// have passed since the trace started. Without nanotime moving forward, trace
// tooling has no way of identifying how much real time each cputicks time deltas
// represent.
for {
trace.endTime = traceClockNow()
trace.endTicks = cputicks()
trace.endNanotime = nanotime()
// Windows time can tick only every 15ms, wait for at least one tick.
if trace.endNanotime != trace.startNanotime {
if trace.endNanotime != trace.startNanotime || faketime != 0 {
break
}
osyield()