Commit ad60cd8b authored by Austin Clements's avatar Austin Clements

runtime: report MemStats.PauseEnd in UNIX time

Currently we report MemStats.PauseEnd in nanoseconds, but with no
particular 0 time. On Linux, the 0 time is when the host started. On
Darwin, it's the UNIX epoch. This is also inconsistent with the other
absolute time in MemStats, LastGC, which is always reported in
nanoseconds since 1970.

Fix PauseEnd so it's always reported in nanoseconds since 1970, like
LastGC.

Fixes one of the issues raised in #10323.

Change-Id: Ie2fe3169d45113992363a03b764f4e6c47e5c6a8
Reviewed-on: https://go-review.googlesource.com/11801
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 0bcdffee
...@@ -44,6 +44,10 @@ func TestMemStats(t *testing.T) { ...@@ -44,6 +44,10 @@ func TestMemStats(t *testing.T) {
if st.HeapIdle+st.HeapInuse != st.HeapSys { if st.HeapIdle+st.HeapInuse != st.HeapSys {
t.Fatalf("HeapIdle(%d) + HeapInuse(%d) should be equal to HeapSys(%d), but isn't.", st.HeapIdle, st.HeapInuse, st.HeapSys) t.Fatalf("HeapIdle(%d) + HeapInuse(%d) should be equal to HeapSys(%d), but isn't.", st.HeapIdle, st.HeapInuse, st.HeapSys)
} }
if lpe := st.PauseEnd[int(st.NumGC+255)%len(st.PauseEnd)]; st.LastGC != lpe {
t.Fatalf("LastGC(%d) != last PauseEnd(%d)", st.LastGC, lpe)
}
} }
func TestStringConcatenationAllocs(t *testing.T) { func TestStringConcatenationAllocs(t *testing.T) {
......
...@@ -1436,9 +1436,10 @@ func gcMark(start_time int64) { ...@@ -1436,9 +1436,10 @@ func gcMark(start_time int64) {
} }
t4 := nanotime() t4 := nanotime()
atomicstore64(&memstats.last_gc, uint64(unixnanotime())) // must be Unix time to make sense to user unixNow := unixnanotime()
atomicstore64(&memstats.last_gc, uint64(unixNow)) // must be Unix time to make sense to user
memstats.pause_ns[memstats.numgc%uint32(len(memstats.pause_ns))] = uint64(t4 - t0) memstats.pause_ns[memstats.numgc%uint32(len(memstats.pause_ns))] = uint64(t4 - t0)
memstats.pause_end[memstats.numgc%uint32(len(memstats.pause_end))] = uint64(t4) memstats.pause_end[memstats.numgc%uint32(len(memstats.pause_end))] = uint64(unixNow)
memstats.pause_total_ns += uint64(t4 - t0) memstats.pause_total_ns += uint64(t4 - t0)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment