mirror of
https://github.com/google/tcmalloc.git
synced 2026-10-28 08:35:56 +08:00
test_999014378
Preparation for unbacking from HugeRegion::Release without pageheap_lock: once the lock is dropped around the syscall, other threads
can Get, Put, and Release on the region mid-unback. UnbackHugepages already
hides the range for that window, but only
ReleaseDuringRelease ever called back into the region during an unback.
Add UnbackWithoutLock, which drops pageheap_lock around the unback and runs a
hook there, standing in for a thread that takes the lock during the drop.
Release is called with pageheap_lock held, as the allocator does. Pin down
the contract the lock-drop change relies on:
* GetDuringUnbackAvoidsRangeInFlight: an allocation during the unback
skips the in-flight range even when it is the best fit, and the range
reads as allocated to GetPageAllocationStatus, AddSpanStats, and
free_backed.
* GetDuringUnbackTakesPendingCandidate: Release picks candidates up
front; one that a concurrent Get took (even a single page) is skipped,
in both forward and adaptive order.
* PutDuringUnback: a Put during the unback (release=false/true) leaves
its own hugepage free-and-backed or unbacks it, without touching the
in-flight range.
* FailedUnbackAfterConcurrentGet: a failed unback restores the range to
the free-and-backed pool alongside concurrent changes, and it can be
allocated and released again.
PiperOrigin-RevId: 999014378
TCMalloc
This repository contains the TCMalloc C++ code.
TCMalloc is Google's customized implementation of C's malloc() and C++'s
operator new used for memory allocation within our C and C++ code. TCMalloc is
a fast, multi-threaded malloc implementation.
Building TCMalloc
Bazel is the official build system for TCMalloc. Experimental support for CMake is available as well.
The TCMalloc Platforms Guide contains information on platform support for TCMalloc.
Documentation
All users of TCMalloc should consult the following documentation resources:
- The TCMalloc Quickstart covers downloading, installing, building, and testing TCMalloc, including incorporating within your codebase.
- The TCMalloc Overview covers the basic architecture of TCMalloc, and how that may affect configuration choices.
- The TCMalloc Reference covers the C and C++ TCMalloc API endpoints.
More advanced usages of TCMalloc may find the following documentation useful:
- The TCMalloc Tuning Guide covers the configuration choices in more depth, and also illustrates other ways to customize TCMalloc. This also covers important operating system-level properties for improving TCMalloc performance.
- The TCMalloc Design Doc covers how TCMalloc works underneath the hood, and why certain design choices were made. Most developers will not need this level of implementation detail.
- The TCMalloc Compatibility Guide which documents our expectations for how our APIs are used.
License
The TCMalloc library is licensed under the terms of the Apache license. See LICENSE for more information.
Disclaimer: This is not an officially supported Google product.
Languages
C++
92.8%
Starlark
3.6%
CMake
2.8%
Assembly
0.6%
C
0.2%