Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: improve heap hugepage utilization #59960

Closed
mknyszek opened this issue May 3, 2023 · 2 comments
Closed

runtime: improve heap hugepage utilization #59960

mknyszek opened this issue May 3, 2023 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mknyszek
Copy link
Contributor

mknyszek commented May 3, 2023

Background

Transparent huge pages (THP) admin guide.
Go scavenging policy. (Implementation details are out-of-date, but linked policy is relevant.)

Motivation

Currently, Go's hugepage-related policies do not play well together and have bit-rotted. The result is that the memory regions the Go runtime chooses to mark as MADV_NOHUGEPAGE and MADV_HUGEPAGE are somewhat haphazard, resulting in memory overuse for small heaps. The memory overuse is upwards of 40% memory overhead in some cases. Turning off huge pages entirely fixes the problem, but leaves CPU performance on the table. This policy also means large heaps might have dense sections that are erroneously mapped as MADV_NOHUGEPAGE, costing up to 1% throughput.

The goal of this work is to eliminate this overhead for small heaps while improving huge page utilization for large heaps.

Design

Full design doc soon. (CL)

TL;DR: Determine which parts of the heap should be backed by huge pages based on near-future density of page allocator chunks. This density heuristic is then also used to delay the background scavenger: only chunks that have been sparse for at least one GC cycle are eligible for scavenging. The scavenger also breaks up hugepages.

@mknyszek mknyszek added the NeedsFix The path to resolution is known, but the work has not been done. label May 3, 2023
@mknyszek mknyszek added this to the Go1.21 milestone May 3, 2023
@mknyszek mknyszek self-assigned this May 3, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 3, 2023
@mknyszek mknyszek closed this as completed May 3, 2023
@mknyszek
Copy link
Contributor Author

mknyszek commented May 3, 2023

Landed in https://go.dev/cl/436395.

@mknyszek mknyszek changed the title runtime: hugepage-aware heap runtime: improve heap hugepage utilization May 3, 2023
@gopherbot
Copy link

Change https://go.dev/cl/492018 mentions this issue: design/59960-heap-hugepage-util.md: add design

gopherbot pushed a commit to golang/proposal that referenced this issue Jun 13, 2023
For golang/go#59960.

Change-Id: I4c6ee87db54952ccacdfa6c66b419356e5842620
Reviewed-on: https://go-review.googlesource.com/c/proposal/+/492018
Reviewed-by: Michael Pratt <mpratt@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Done
Development

No branches or pull requests

2 participants