summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/scudo/scudo_allocator.h
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-04-20 18:07:17 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-04-20 18:07:17 +0000
commitfff8e0620b38254314fe65e01e3c8d7c46c0b047 (patch)
treed79544234b8ef422d470cf527115bc496bef9276 /compiler-rt/lib/scudo/scudo_allocator.h
parent13985cd111d95e70c1001f4325cbdb5ec644088c (diff)
downloadbcm5719-llvm-fff8e0620b38254314fe65e01e3c8d7c46c0b047.tar.gz
bcm5719-llvm-fff8e0620b38254314fe65e01e3c8d7c46c0b047.zip
[scudo] Remove GetActuallyAllocatedSize calls from the fast path
Summary: GetActuallyAllocatedSize is actually expensive. In order to avoid calling this function in the malloc/free fast path, we change the Scudo chunk header to store the size of the chunk, if from the Primary, or the amount of unused bytes if from the Secondary. This way, we only have to call the culprit function for Secondary backed allocations (and still in realloc). The performance gain on a singly threaded pure malloc/free benchmark exercising the Primary allocator is above 5%. Reviewers: alekseyshl, kcc, dvyukov Reviewed By: dvyukov Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32299 llvm-svn: 300861
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_allocator.h')
-rw-r--r--compiler-rt/lib/scudo/scudo_allocator.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/compiler-rt/lib/scudo/scudo_allocator.h b/compiler-rt/lib/scudo/scudo_allocator.h
index 1696e1389c7..e7428f17027 100644
--- a/compiler-rt/lib/scudo/scudo_allocator.h
+++ b/compiler-rt/lib/scudo/scudo_allocator.h
@@ -44,15 +44,17 @@ enum ChunkState : u8 {
// well. The header will be atomically loaded and stored.
typedef u64 PackedHeader;
struct UnpackedHeader {
- u64 Checksum : 16;
- u64 UnusedBytes : 20; // Needed for reallocation purposes.
- u64 State : 2; // available, allocated, or quarantined
- u64 AllocType : 2; // malloc, new, new[], or memalign
- u64 Offset : 16; // Offset from the beginning of the backend
- // allocation to the beginning of the chunk itself,
- // in multiples of MinAlignment. See comment about
- // its maximum value and test in init().
- u64 Salt : 8;
+ u64 Checksum : 16;
+ u64 SizeOrUnusedBytes : 19; // Size for Primary backed allocations, amount of
+ // unused bytes in the chunk for Secondary ones.
+ u64 FromPrimary : 1;
+ u64 State : 2; // available, allocated, or quarantined
+ u64 AllocType : 2; // malloc, new, new[], or memalign
+ u64 Offset : 16; // Offset from the beginning of the backend
+ // allocation to the beginning of the chunk
+ // itself, in multiples of MinAlignment. See
+ /// comment about its maximum value and in init().
+ u64 Salt : 8;
};
typedef atomic_uint64_t AtomicPackedHeader;
OpenPOWER on IntegriCloud