Skip to content

Commit

Permalink
Fix MmapAllocator::toString (#8300)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #8300

Reviewed By: bikramSingh91

Differential Revision: D52646151

Pulled By: xiaoxmeng

fbshipit-source-id: eed145aea959721f4fba9ae21dc87da22321a2af
majetideepak authored and facebook-github-bot committed Jan 10, 2024
1 parent 5d47574 commit 62caa6a
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion velox/common/caching/tests/AsyncDataCacheTest.cpp
Original file line number Diff line number Diff line change
@@ -877,7 +877,7 @@ TEST_F(AsyncDataCacheTest, cacheStats) {
"Prefetch entries: 0 bytes: 0B\n"
"Alloc Megaclocks 0\n"
"Allocated pages: 0 cached pages: 0\n"
"Backing: Memory Allocator[MMAP capacity 16.00KB allocated pages 0 mapped pages 0 external mapped pages 0\n"
"Backing: Memory Allocator[MMAP total capacity 64.00MB free capacity 64.00MB allocated pages 0 mapped pages 0 external mapped pages 0\n"
"[size 1: 0(0MB) allocated 0 mapped]\n"
"[size 2: 0(0MB) allocated 0 mapped]\n"
"[size 4: 0(0MB) allocated 0 mapped]\n"
9 changes: 7 additions & 2 deletions velox/common/memory/MmapAllocator.cpp
Original file line number Diff line number Diff line change
@@ -1028,8 +1028,13 @@ bool MmapAllocator::useMalloc(uint64_t bytes) {

std::string MmapAllocator::toString() const {
std::stringstream out;
out << "Memory Allocator[" << kindString(kind_) << " capacity "
<< ((capacity_ == kMaxMemory) ? "UNLIMITED" : succinctBytes(capacity_))
out << "Memory Allocator[" << kindString(kind_) << " total capacity "
<< ((capacity_ == kMaxMemory) ? "UNLIMITED" : succinctBytes(capacity()))
<< " free capacity "
<< ((capacity_ == kMaxMemory)
? "UNLIMITED"
: succinctBytes(
capacity() - AllocationTraits::pageBytes(numAllocated())))
<< " allocated pages " << numAllocated_ << " mapped pages " << numMapped_
<< " external mapped pages " << numExternalMapped_ << std::endl;
for (auto& sizeClass : sizeClasses_) {
2 changes: 1 addition & 1 deletion velox/common/memory/tests/MemoryAllocatorTest.cpp
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ class MemoryAllocatorTest : public testing::TestWithParam<bool> {
ASSERT_EQ(instance_->kind(), MemoryAllocator::Kind::kMmap);
ASSERT_EQ(
instance_->toString(),
"Memory Allocator[MMAP capacity 256.00KB allocated pages 0 mapped pages 0 external mapped pages 0\n[size 1: 0(0MB) allocated 0 mapped]\n[size 2: 0(0MB) allocated 0 mapped]\n[size 4: 0(0MB) allocated 0 mapped]\n[size 8: 0(0MB) allocated 0 mapped]\n[size 16: 0(0MB) allocated 0 mapped]\n[size 32: 0(0MB) allocated 0 mapped]\n[size 64: 0(0MB) allocated 0 mapped]\n[size 128: 0(0MB) allocated 0 mapped]\n[size 256: 0(0MB) allocated 0 mapped]\n]");
"Memory Allocator[MMAP total capacity 1.00GB free capacity 1.00GB allocated pages 0 mapped pages 0 external mapped pages 0\n[size 1: 0(0MB) allocated 0 mapped]\n[size 2: 0(0MB) allocated 0 mapped]\n[size 4: 0(0MB) allocated 0 mapped]\n[size 8: 0(0MB) allocated 0 mapped]\n[size 16: 0(0MB) allocated 0 mapped]\n[size 32: 0(0MB) allocated 0 mapped]\n[size 64: 0(0MB) allocated 0 mapped]\n[size 128: 0(0MB) allocated 0 mapped]\n[size 256: 0(0MB) allocated 0 mapped]\n]");
} else {
ASSERT_EQ(instance_->kind(), MemoryAllocator::Kind::kMalloc);
ASSERT_EQ(

0 comments on commit 62caa6a

Please sign in to comment.