Skip to content

runtime: improve heap hugepage utilization #59960

Closed

Description

@mknyszek

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.

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on May 3, 2023
  2. added this to the Go1.21 milestone on May 3, 2023
  3. self-assigned this
    on May 3, 2023
  4. mknyszek commented on May 3, 2023

    @mknyszek
    ContributorAuthor
  5. changed the title [-]runtime: hugepage-aware heap[/-] [+]runtime: improve heap hugepage utilization[/+] on May 3, 2023
  6. gopherbot commented on May 3, 2023

    @gopherbot
    Contributor

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

  7. gopherbot commented on Oct 2, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/531816 mentions this issue: runtime: don't eagerly collapse hugepages

  8. gopherbot commented on Oct 2, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/532117 mentions this issue: runtime: delete hugepage tracking dead code

  9. gopherbot commented on Oct 2, 2023

    @gopherbot
    Contributor

    Change https://go.dev/cl/532255 mentions this issue: [release-branch.go1.21] runtime: don't eagerly collapse hugepages

  10. locked and limited conversation to collaborators on Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions