From a2cd2bd55d1e932b52f0b7dea45a85e058fc77d5 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 16 Sep 2019 21:23:24 +0000 Subject: runtime: add per-p page allocation cache This change adds a per-p free page cache which the page allocator may allocate out of without a lock. The change also introduces a completely lockless page allocator fast path. Although the cache contains at most 64 pages (and usually less), the vast majority (85%+) of page allocations are exactly 1 page in size. Updates #35112. Change-Id: I170bf0a9375873e7e3230845eb1df7e5cf741b78 Reviewed-on: https://go-review.googlesource.com/c/go/+/195701 Run-TryBot: Michael Knyszek Reviewed-by: Austin Clements --- src/runtime/malloc_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/runtime/malloc_test.go') diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go index 1040fb6a8f..5ed4feb77d 100644 --- a/src/runtime/malloc_test.go +++ b/src/runtime/malloc_test.go @@ -168,6 +168,14 @@ func TestTinyAlloc(t *testing.T) { } } +func TestPageCacheLeak(t *testing.T) { + defer GOMAXPROCS(GOMAXPROCS(1)) + leaked := PageCachePagesLeaked() + if leaked != 0 { + t.Fatalf("found %d leaked pages in page caches", leaked) + } +} + func TestPhysicalMemoryUtilization(t *testing.T) { got := runTestProg(t, "testprog", "GCPhys") want := "OK\n" -- cgit v1.3