diff --git a/tcmalloc/central_freelist_benchmark.cc b/tcmalloc/central_freelist_benchmark.cc index 552ae84af..598fc1c43 100644 --- a/tcmalloc/central_freelist_benchmark.cc +++ b/tcmalloc/central_freelist_benchmark.cc @@ -50,13 +50,8 @@ namespace { void* BenchmarkMetaDataAlloc(size_t bytes) { return ::operator new(bytes); } -#ifdef TCMALLOC_USE_PAGEMAP3 using BenchmarkPageMap = PageMap3; -#else -using BenchmarkPageMap = - PageMap2; -#endif // BenchmarkStaticForwarder provides a wrapper around ordinary TCMalloc and a // PageMap to allow us to carve up memory we obtained into our own objects. diff --git a/tcmalloc/common.h b/tcmalloc/common.h index d17e94b78..936e6e19c 100644 --- a/tcmalloc/common.h +++ b/tcmalloc/common.h @@ -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) diff --git a/tcmalloc/pagemap.cc b/tcmalloc/pagemap.cc index 763282435..2a5152046 100644 --- a/tcmalloc/pagemap.cc +++ b/tcmalloc/pagemap.cc @@ -50,27 +50,6 @@ void PageMap::UnregisterSizeClass(Span* span) { } } -void PageMap::MapRootWithSmallPages() { - constexpr size_t kHugePageMask = ~(kHugePageSize - 1); - uintptr_t begin = reinterpret_cast(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(rbegin), rlength, MADV_NOHUGEPAGE); - } -} - void* MetaDataAlloc(size_t bytes) { return tc_globals.arena().Alloc(bytes); } } // namespace tcmalloc_internal diff --git a/tcmalloc/pagemap.h b/tcmalloc/pagemap.h index 6519e246e..b4ec3362d 100644 --- a/tcmalloc/pagemap.h +++ b/tcmalloc/pagemap.h @@ -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 @@ -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 { @@ -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 @@ -648,11 +636,7 @@ class PageMap { } private: -#ifdef TCMALLOC_USE_PAGEMAP3 PageMap3 map_; -#else - PageMap2 map_; -#endif }; } // namespace tcmalloc_internal diff --git a/tcmalloc/static_vars.cc b/tcmalloc/static_vars.cc index aac97045d..149970a3d 100644 --- a/tcmalloc/static_vars.cc +++ b/tcmalloc/static_vars.cc @@ -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); diff --git a/tcmalloc/testing/fast_path.aarch64+opt.golden b/tcmalloc/testing/fast_path.aarch64+opt.golden index 9a4e0394f..d161832af 100644 --- a/tcmalloc/testing/fast_path.aarch64+opt.golden +++ b/tcmalloc/testing/fast_path.aarch64+opt.golden @@ -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 diff --git a/tcmalloc/testing/fast_path.insecure.golden b/tcmalloc/testing/fast_path.insecure.golden index 8244992d8..07b48a8f4 100644 --- a/tcmalloc/testing/fast_path.insecure.golden +++ b/tcmalloc/testing/fast_path.insecure.golden @@ -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 diff --git a/tcmalloc/testing/fast_path.opt.golden b/tcmalloc/testing/fast_path.opt.golden index 8af92e101..6fc69a987 100644 --- a/tcmalloc/testing/fast_path.opt.golden +++ b/tcmalloc/testing/fast_path.opt.golden @@ -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 diff --git a/tcmalloc/testing/fast_path.release+insecure.golden b/tcmalloc/testing/fast_path.release+insecure.golden index 028517776..07b48a8f4 100644 --- a/tcmalloc/testing/fast_path.release+insecure.golden +++ b/tcmalloc/testing/fast_path.release+insecure.golden @@ -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 @@ -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 diff --git a/tcmalloc/testing/fast_path.release.golden b/tcmalloc/testing/fast_path.release.golden index 028517776..07b48a8f4 100644 --- a/tcmalloc/testing/fast_path.release.golden +++ b/tcmalloc/testing/fast_path.release.golden @@ -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 @@ -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 diff --git a/tcmalloc/testing/startup_size_test.cc b/tcmalloc/testing/startup_size_test.cc index acae6ea60..8789b7aa4 100644 --- a/tcmalloc/testing/startup_size_test.cc +++ b/tcmalloc/testing/startup_size_test.cc @@ -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;