diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2019-04-29 21:02:18 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2019-05-06 20:59:20 +0000 |
commit | f4a5ae5594a21ea276d473fe9f804a30adbd8d07 (patch) | |
tree | 64d2d4d5dfc4135270e877c2778c49b530cc8ae0 /src/runtime/gc_test.go | |
parent | a62b5723be15849656279c244834064b951801fc (diff) | |
download | go-f4a5ae5594a21ea276d473fe9f804a30adbd8d07.tar.gz go-f4a5ae5594a21ea276d473fe9f804a30adbd8d07.zip |
runtime: track the number of free unscavenged huge pages
This change tracks the number of potential free and unscavenged huge
pages which will be used to inform the rate at which scavenging should
occur.
For #30333.
Change-Id: I47663e5ffb64cac44ffa10db158486783f707479
Reviewed-on: https://go-review.googlesource.com/c/go/+/170860
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/gc_test.go')
-rw-r--r-- | src/runtime/gc_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go index 51e8ea4d31..d55a934519 100644 --- a/src/runtime/gc_test.go +++ b/src/runtime/gc_test.go @@ -470,6 +470,25 @@ func TestReadMemStats(t *testing.T) { } } +func TestUnscavHugePages(t *testing.T) { + // Allocate 20 MiB and immediately free it a few times to increase + // the chance that unscavHugePages isn't zero and that some kind of + // accounting had to happen in the runtime. + for j := 0; j < 3; j++ { + var large [][]byte + for i := 0; i < 5; i++ { + large = append(large, make([]byte, runtime.PhysHugePageSize)) + } + runtime.KeepAlive(large) + runtime.GC() + } + base, slow := runtime.UnscavHugePagesSlow() + if base != slow { + logDiff(t, "unscavHugePages", reflect.ValueOf(base), reflect.ValueOf(slow)) + t.Fatal("unscavHugePages mismatch") + } +} + func logDiff(t *testing.T, prefix string, got, want reflect.Value) { typ := got.Type() switch typ.Kind() { |