Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions tcmalloc/central_freelist_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ namespace {

void* BenchmarkMetaDataAlloc(size_t bytes) { return ::operator new(bytes); }

#ifdef TCMALLOC_USE_PAGEMAP3
using BenchmarkPageMap =
PageMap3<kAddressBits - kPageShift, BenchmarkMetaDataAlloc>;
#else
using BenchmarkPageMap =
PageMap2<kAddressBits - kPageShift, BenchmarkMetaDataAlloc>;
#endif

// BenchmarkStaticForwarder provides a wrapper around ordinary TCMalloc and a
// PageMap to allow us to carve up memory we obtained into our own objects.
Expand Down
1 change: 0 additions & 1 deletion tcmalloc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ static_assert(sizeof(void*) == 8);
#ifndef TCMALLOC_PAGE_SHIFT
#ifdef TCMALLOC_INTERNAL_SMALL_BUT_SLOW
#define TCMALLOC_PAGE_SHIFT 12
#define TCMALLOC_USE_PAGEMAP3
#elif defined(TCMALLOC_INTERNAL_256K_PAGES)
#define TCMALLOC_PAGE_SHIFT 18
#elif defined(TCMALLOC_INTERNAL_32K_PAGES)
Expand Down
21 changes: 0 additions & 21 deletions tcmalloc/pagemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,6 @@ void PageMap::UnregisterSizeClass(Span* span) {
}
}

void PageMap::MapRootWithSmallPages() {
constexpr size_t kHugePageMask = ~(kHugePageSize - 1);
uintptr_t begin = reinterpret_cast<uintptr_t>(map_.RootAddress());
// Round begin up to the nearest hugepage, this avoids causing memory before
// the start of the pagemap to become mapped onto small pages.
uintptr_t rbegin = (begin + kHugePageSize - 1) & kHugePageMask;
size_t length = map_.RootSize();
// Round end down to the nearest hugepage, this avoids causing memory after
// the end of the pagemap becoming mapped onto small pages.
size_t rend = (begin + length) & kHugePageMask;
// Since we have rounded the start up, and the end down, we also want to
// confirm that there is something left between them for us to modify.
// For small but slow, the root pagemap is less than a hugepage in size,
// so we will not end up forcing it to be small pages.
if (rend > rbegin) {
size_t rlength = rend - rbegin;
ErrnoRestorer errno_restorer;
madvise(reinterpret_cast<void*>(rbegin), rlength, MADV_NOHUGEPAGE);
}
}

void* MetaDataAlloc(size_t bytes) { return tc_globals.arena().Alloc(bytes); }

} // namespace tcmalloc_internal
Expand Down
16 changes: 0 additions & 16 deletions tcmalloc/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ class PageMap2 {
// Account for size of root node, etc.
return bytes_used_ + sizeof(*this);
}

constexpr size_t RootSize() const { return sizeof(root_); }
const void* RootAddress() { return root_; }
};

// Three-level radix tree
Expand Down Expand Up @@ -527,9 +524,6 @@ class PageMap3 {
}

size_t bytes_used() const { return bytes_used_ + sizeof(*this); }

constexpr size_t RootSize() const { return sizeof(root_); }
const void* RootAddress() { return root_; }
};

class PageMap {
Expand Down Expand Up @@ -606,12 +600,6 @@ class PageMap {

void SetHugepage(PageId p, void* v) { map_.set_hugepage(p.index(), v); }

// The PageMap root node can be quite large and sparsely used. If this
// gets mapped with hugepages we potentially end up holding a large
// amount of unused memory. So it is better to map the root node with
// small pages to minimise the amount of unused memory.
void MapRootWithSmallPages();

// Returns the count of the currently allocated Spans and also adds details
// of such Spans in the provided allocated_spans vector. This routine avoids
// allocation events since we hold the pageheap_lock, so no more elements will
Expand Down Expand Up @@ -648,11 +636,7 @@ class PageMap {
}

private:
#ifdef TCMALLOC_USE_PAGEMAP3
PageMap3<kAddressBits - kPageShift, MetaDataAlloc> map_;
#else
PageMap2<kAddressBits - kPageShift, MetaDataAlloc> map_;
#endif
};

} // namespace tcmalloc_internal
Expand Down
1 change: 0 additions & 1 deletion tcmalloc/static_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ ABSL_ATTRIBUTE_COLD ABSL_ATTRIBUTE_NOINLINE void Static::SlowInitIfNecessary() {
// state.
sharded_transfer_cache_.Init();
new (page_allocator_.memory) PageAllocator;
pagemap_.MapRootWithSmallPages();
guardedpage_allocator_.Init(/*max_allocated_pages=*/64,
/*total_pages=*/128);

Expand Down
2 changes: 1 addition & 1 deletion tcmalloc/testing/fast_path.aarch64+opt.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
func call cmov cmp div jcc jmp load mul pop push rmw rsp store
aligned_alloc - - 4 - 7 - 8 - - - - 3 4
calloc - - 2 - 6 - 9 2 - - - 5 5
delete - - 2 - 5 - 6 - - - - - 3
delete - - 2 - 6 - 7 - - - - - 3
delete(size) - - 3 - 5 - 5 - - - - - 3
delete(size,align) - - 5 - 7 - 6 - - - - - 3
malloc - - 2 - 5 - 7 - - - - - 3
Expand Down
2 changes: 1 addition & 1 deletion tcmalloc/testing/fast_path.insecure.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
func call cmov cmp div jcc jmp load mul pop push rmw rsp store
aligned_alloc - - 6 - 7 - 6 - 2 1 1 1 2
calloc - - 4 - 6 - 6 1 2 3 1 2 2
delete - - 5 - 5 - 5 - - - - - 3
delete - - 6 - 6 - 6 - - - - - 3
delete(size) - - 5 - 5 - 4 - - - - - 3
delete(size,align) - - 7 - 7 - 5 - - - - - 3
malloc - - 4 - 5 - 6 - - - 1 - 2
Expand Down
2 changes: 1 addition & 1 deletion tcmalloc/testing/fast_path.opt.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
func call cmov cmp div jcc jmp load mul pop push rmw rsp store
aligned_alloc - - 6 - 7 - 6 - 2 1 1 1 2
calloc - - 4 - 6 - 6 1 2 3 1 2 2
delete - - 5 - 5 - 5 - - - - - 3
delete - - 6 - 6 - 6 - - - - - 3
delete(size) - - 5 - 5 - 4 - - - - - 3
delete(size,align) - - 7 - 7 - 5 - - - - - 3
malloc - - 4 - 5 - 6 - - - 1 - 2
Expand Down
4 changes: 2 additions & 2 deletions tcmalloc/testing/fast_path.release+insecure.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
func call cmov cmp div jcc jmp load mul pop push rmw rsp store
aligned_alloc - - 6 - 7 - 6 - 2 1 1 1 2
calloc - - 4 - 6 - 6 1 2 3 1 2 2
delete - - 5 - 5 - 5 - - - - - 3
delete - - 6 - 6 - 6 - - - - - 3
delete(size) - - 5 - 5 - 4 - - - - - 3
delete(size,align) - - 7 - 7 - 5 - - - - - 3
malloc - - 4 - 5 - 6 - - - 1 - 2
Expand All @@ -12,7 +12,7 @@ new(align)->size - - 5 - 6 - 7 - - - 1 -
new(align,cold)->size - 1 6 - 6 - 8 - - - 1 - 2
new(align,nothrow) - - 5 - 6 - 6 - - - 1 - 2
new(cold)->size - 1 4 - 4 - 7 - - - 1 - 2
new(cold,token_1)->size - - 4 - 5 - 7 - - - 1 - 2
new(cold,token_1)->size - 1 4 - 4 - 7 - - - 1 - 2
new(nothrow) - - 3 - 4 - 5 - - - 1 - 2
new(token_1) - - 3 - 4 - 5 - - - 1 - 2
new(token_1)->size - - 3 - 4 - 6 - - - 1 - 2
Expand Down
4 changes: 2 additions & 2 deletions tcmalloc/testing/fast_path.release.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
func call cmov cmp div jcc jmp load mul pop push rmw rsp store
aligned_alloc - - 6 - 7 - 6 - 2 1 1 1 2
calloc - - 4 - 6 - 6 1 2 3 1 2 2
delete - - 5 - 5 - 5 - - - - - 3
delete - - 6 - 6 - 6 - - - - - 3
delete(size) - - 5 - 5 - 4 - - - - - 3
delete(size,align) - - 7 - 7 - 5 - - - - - 3
malloc - - 4 - 5 - 6 - - - 1 - 2
Expand All @@ -12,7 +12,7 @@ new(align)->size - - 5 - 6 - 7 - - - 1 -
new(align,cold)->size - 1 6 - 6 - 8 - - - 1 - 2
new(align,nothrow) - - 5 - 6 - 6 - - - 1 - 2
new(cold)->size - 1 4 - 4 - 7 - - - 1 - 2
new(cold,token_1)->size - - 4 - 5 - 7 - - - 1 - 2
new(cold,token_1)->size - 1 4 - 4 - 7 - - - 1 - 2
new(nothrow) - - 3 - 4 - 5 - - - 1 - 2
new(token_1) - - 3 - 4 - 5 - - - 1 - 2
new(token_1)->size - - 3 - 4 - 6 - - - 1 - 2
Expand Down
2 changes: 1 addition & 1 deletion tcmalloc/testing/startup_size_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST(StartupSizeTest, Basic) {
#ifdef __powerpc64__
size_t metadata_limit = 36.5 * MiB;
#else
size_t metadata_limit = 28 * MiB;
size_t metadata_limit = 17 * MiB;
#endif
// Check whether per-cpu is active
size_t upper_percpu_limit = 0;
Expand Down
Loading