linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yu Zhao <yuzhao@google.com>
To: lsf-pc@lists.linux-foundation.org
Cc: linux-mm@kvack.org, Jonathan Corbet <corbet@lwn.net>,
	Yu Zhao <yuzhao@google.com>
Subject: [Epilogue] Profile-Guided Heap Optimization and THP fungibility
Date: Thu, 29 Feb 2024 11:34:36 -0700	[thread overview]
Message-ID: <20240229183436.4110845-5-yuzhao@google.com> (raw)
In-Reply-To: <20240229183436.4110845-1-yuzhao@google.com>

In a nutshell, Profile-Guided Heap Optimization (PGHO) [1] allows
userspace memory allocators, e.g., TCMalloc [2], to
1. Group memory objects by hotness so that the accessed bit in the PMD
   entry mapping a THP can better reflect the overall hotness of that
   THP. A counterexample is a single hot page shielding the rest of
   the cold pages in that THP from being reclaimed.
2. Group objects by lifetime to reduce the chance of split. Frequency
   split increases the entropy of a system and can cause a higher
   consumption of physical contiguity and reduced overall performance
   (due to TLB misses [2]).

None of PGOs (PGHO included) can account for every runtime behavior.
For example, an object predicated hot or long-lived can turn out to be
cold or short-lived. However, the kernel may not be able to reclaim
the THP containing that object because of the aforementioned reasons.
Instead, userspace memory allocators can choose to MADV_COLD or
MADV_FREE that object to avoid reclaiming other hot folios or OOM
kills. This is part of the whole process, called THP fungibility, and
it ends up with the split of the THP containing that object.

The full circle completes after userspace memory allocators recover
the THP from the split above. This part, called MADV_RECOVER, is done
by "collapsing" the pages of the original THP in place. Pages that
have been reused since the split are either reclaimed or migrated so
that they can become free again. Compared with MADV_COLLAPSE,
MADV_RECOVER has the following advantages:
1. It is more likely to succeed, since it does not try to allocate a
   new THP.
2. It does not copy the pages that are already in place and therefore
   has a smaller window during which the hot objects in those pages
   are inaccessible.

In essence, THP fungibility is a cooperation between the userspace
memory allocator and TAO to better utilize physical contiguity in a
system. It extends the heuristics for the bin packing problem from the
allocation time (mobility and size as described in Chapter One) to the
runtime (hotness and lifetime). Machine learning is likely to become
the autotuner in the foreseeable future, just as it has with the
software-defined far memory at Google [3].

[1] https://lists.llvm.org/pipermail/llvm-dev/2020-June/142744.html
[2] https://www.usenix.org/conference/osdi21/presentation/hunter
[3] https://research.google/pubs/software-defined-far-memory-in-warehouse-scale-computers/
-- 
2.44.0.rc1.240.g4c46232300-goog



  parent reply	other threads:[~2024-02-29 18:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 18:34 [LSF/MM/BPF TOPIC] TAO: THP Allocator Optimizations Yu Zhao
2024-02-29 18:34 ` [Chapter One] THP zones: the use cases of policy zones Yu Zhao
2024-02-29 20:28   ` Matthew Wilcox
2024-03-06  3:51     ` Yu Zhao
2024-03-06  4:33       ` Matthew Wilcox
2024-02-29 23:31   ` Yang Shi
2024-03-03  2:47     ` Yu Zhao
2024-03-04 15:19   ` Matthew Wilcox
2024-03-05 17:22     ` Matthew Wilcox
2024-03-05  8:41   ` Barry Song
2024-03-05 10:07     ` Vlastimil Babka
2024-03-05 21:04       ` Barry Song
2024-03-06  3:05         ` Yu Zhao
2024-05-24  8:38   ` Barry Song
2024-11-01  2:35   ` Charan Teja Kalla
2024-11-01 16:55     ` Yu Zhao
2024-02-29 18:34 ` [Chapter Two] THP shattering: the reverse of collapsing Yu Zhao
2024-02-29 21:55   ` Zi Yan
2024-03-03  1:17     ` Yu Zhao
2024-03-03  1:21       ` Zi Yan
2024-06-11  8:32   ` Barry Song
2024-02-29 18:34 ` [Chapter Three] THP HVO: bring the hugeTLB feature to THP Yu Zhao
2024-02-29 22:54   ` Yang Shi
2024-03-01 15:42     ` David Hildenbrand
2024-03-03  1:46     ` Yu Zhao
2024-02-29 18:34 ` Yu Zhao [this message]
2024-03-05  8:37 ` [LSF/MM/BPF TOPIC] TAO: THP Allocator Optimizations Barry Song
2024-03-06 15:51 ` Johannes Weiner
2024-03-06 16:40   ` Zi Yan
2024-03-13 22:09   ` Kaiyang Zhao
2024-05-15 21:17 ` Yu Zhao
2024-05-15 21:52   ` Yu Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240229183436.4110845-5-yuzhao@google.com \
    --to=yuzhao@google.com \
    --cc=corbet@lwn.net \
    --cc=linux-mm@kvack.org \
    --cc=lsf-pc@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox