Skip to content

Commit 7cd6cff

Browse files
committed
Add support for PartitionAlloc
This change adds support for PartitionAlloc, the memory allocator used in chromium. Normally the allocator is build in-tree, but this pulls in a standalone version. The standalone version added here should be updated as soon as the official repository of PartitionAlloc (https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator) supports standalone builds.
1 parent b82aafd commit 7cd6cff

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ for the versions:
9696
- **mi**: The [_mimalloc_](https://github.com/microsoft/mimalloc) allocator.
9797
We can also test the debug version as **dmi** (this can be used to check for
9898
any bugs in the benchmarks), and the secure version as **smi**.
99+
- **pa**: The [_PartitionAlloc_] allocator used in Chromium.
99100
- **rp**: The [_rpmalloc_](https://github.com/mjansson/rpmalloc) allocator uses
100101
16-byte aligned allocations and is developed by [Mattias
101102
Jansson](https://twitter.com/maniccoder) at Epic Games, used for example

bench.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Allocators and tests
77
# --------------------------------------------------------------------
88

9-
readonly alloc_all="sys dh ff fg gd hd hm hml iso je lp lt mi mi-sec mng mesh nomesh rp sc scudo sg sm sn sn-sec tbb tc tcg dmi xmi xsmi xdmi"
10-
readonly alloc_secure="dh ff gd hm hml iso mi-sec mng scudo sg sn-sec sg"
9+
readonly alloc_all="sys dh ff fg gd hd hm hml iso je lp lt mi mi-sec mng mesh nomesh pa rp sc scudo sg sm sn sn-sec tbb tc tcg dmi xmi xsmi xdmi"
10+
readonly alloc_secure="dh ff gd hm hml iso mi-sec mng pa scudo sg sn-sec sg"
1111
alloc_run="" # allocators to run (expanded by command line options)
1212
alloc_installed="sys" # later expanded to include all installed allocators
1313
alloc_libs="sys=" # mapping from allocator to its .so as "<allocator>=<sofile> ..."
@@ -112,6 +112,7 @@ alloc_lib_add "lt" "$localdevdir/lt/gnu.make.lib/libltalloc$extso"
112112
alloc_lib_add "mesh" "$localdevdir/mesh/build/lib/libmesh$extso"
113113
alloc_lib_add "mng" "$localdevdir/mng/libmallocng$extso"
114114
alloc_lib_add "nomesh" "$localdevdir/nomesh/build/lib/libmesh$extso"
115+
alloc_lib_add "pa" "$localdevdir/pa/partition_alloc_builder/out/Default/libpalib$extso"
115116
alloc_lib_add "rp" "$lib_rp"
116117
alloc_lib_add "sc" "$localdevdir/sc/out/Release/lib.target/libscalloc$extso"
117118
alloc_lib_add "scudo" "$localdevdir/scudo/compiler-rt/lib/scudo/standalone/libscudo$extso"
@@ -392,6 +393,7 @@ while : ; do
392393
echo " mi-sec use secure version of mimalloc"
393394
echo " mng use mallocng"
394395
echo " nomesh use mesh with meshing disabled"
396+
echo " pa use PartitionAlloc"
395397
echo " rp use rpmalloc"
396398
echo " sc use scalloc"
397399
echo " scudo use scudo"

build-bench-env.sh

+23
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ readonly version_mesh=master # ~unmaintained since 2021
4747
readonly version_mi=v1.7.7
4848
readonly version_mng=master # ~unmaintained
4949
readonly version_nomesh=$version_mesh
50+
readonly version_pa=main
5051
readonly version_rp=f4732ee # https://github.com/mjansson/rpmalloc/issues/293#issuecomment-1336502654
5152
readonly version_sc=master # unmaintained since 2016
5253
readonly version_scudo=main
@@ -79,6 +80,7 @@ setup_mesh=0
7980
setup_mi=0
8081
setup_mng=0
8182
setup_nomesh=0
83+
setup_pa=0
8284
setup_rp=0
8385
setup_sc=0
8486
setup_scudo=0
@@ -123,6 +125,7 @@ while : ; do
123125
setup_je=$flag_arg
124126
setup_lp=$flag_arg
125127
setup_mi=$flag_arg
128+
setup_pa=$flag_arg
126129
setup_sn=$flag_arg
127130
setup_sg=$flag_arg
128131
setup_tbb=$flag_arg
@@ -187,6 +190,8 @@ while : ; do
187190
setup_mi=$flag_arg;;
188191
nomesh)
189192
setup_nomesh=$flag_arg;;
193+
pa)
194+
setup_pa=$flag_arg;;
190195
packages)
191196
setup_packages=$flag_arg;;
192197
redis)
@@ -238,6 +243,7 @@ while : ; do
238243
echo " mi setup mimalloc ($version_mi)"
239244
echo " mng setup mallocng ($version_mng)"
240245
echo " nomesh setup mesh allocator w/o meshing ($version_mesh)"
246+
echo " pa setup PartitionAlloc ($version_pa)"
241247
echo " rp setup rpmalloc ($version_rp)"
242248
echo " sc setup scalloc ($version_sc)"
243249
echo " scudo setup scudo ($version_scudo)"
@@ -497,6 +503,23 @@ if test "$setup_lt" = "1"; then
497503
popd
498504
fi
499505

506+
if test "$setup_pa" = "1"; then
507+
checkout pa $version_pa https://github.com/1c3t3a/partition_alloc_builder.git
508+
509+
# Setup depot_tools for building
510+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
511+
export PATH="$PATH:${pwd}/depot_tools"
512+
513+
# Fetch sources - this relies on a standalone build of PA
514+
gclient config https://github.com/1c3t3a/partition_alloc_builder.git
515+
gclient sync
516+
cd partition_alloc_builder
517+
518+
gn gen out/Default
519+
autoninja -C out/Default
520+
popd
521+
fi
522+
500523
if test "$setup_sg" = "1"; then
501524
checkout sg $version_sg https://github.com/ssrg-vt/SlimGuard
502525
make -j $procs

0 commit comments

Comments
 (0)