diff --git a/velox/common/memory/MemoryAllocator.cpp b/velox/common/memory/MemoryAllocator.cpp index 3995b18419299..e4dd46457b3a4 100644 --- a/velox/common/memory/MemoryAllocator.cpp +++ b/velox/common/memory/MemoryAllocator.cpp @@ -364,15 +364,18 @@ std::string Stats::toString() const { std::stringstream out; int64_t totalClocks = 0; int64_t totalBytes = 0; + int64_t totalAllocations = 0; for (auto i = 0; i < sizes.size(); ++i) { totalClocks += sizes[i].clocks(); totalBytes += sizes[i].totalBytes; + totalAllocations += sizes[i].numAllocations; } out << fmt::format( - "Alloc: {}MB {} Gigaclocks, {}MB advised\n", + "Alloc: {}MB {} Gigaclocks {} Allocations, {}MB advised\n", totalBytes >> 20, totalClocks >> 30, - numAdvise >> 8); + numAdvise >> 8, + totalAllocations); // Sort the size classes by decreasing clocks. std::vector indices(sizes.size()); @@ -386,10 +389,11 @@ std::string Stats::toString() const { break; } out << fmt::format( - "Size {}K: {}MB {} Megaclocks\n", + "Size {}K: {}MB {} Megaclocks {} Allocations\n", sizes[i].size * 4, sizes[i].totalBytes >> 20, - sizes[i].clocks() >> 20); + sizes[i].clocks() >> 20, + sizes[i].numAllocations); } return out.str(); } diff --git a/velox/common/memory/tests/MemoryAllocatorTest.cpp b/velox/common/memory/tests/MemoryAllocatorTest.cpp index 86133a88e2bf3..deacf0d66be5f 100644 --- a/velox/common/memory/tests/MemoryAllocatorTest.cpp +++ b/velox/common/memory/tests/MemoryAllocatorTest.cpp @@ -636,6 +636,8 @@ TEST_P(MemoryAllocatorTest, singleAllocation) { if (!useMmap_ && enableReservation_) { return; } + gflags::FlagSaver flagSaver; + FLAGS_velox_time_allocations = true; const std::vector& sizes = instance_->sizeClasses(); MachinePageCount capacity = kCapacityPages; for (auto i = 0; i < sizes.size(); ++i) { diff --git a/velox/flag_definitions/flags.cpp b/velox/flag_definitions/flags.cpp index d25ae44713f1b..b26eeb5d4c704 100644 --- a/velox/flag_definitions/flags.cpp +++ b/velox/flag_definitions/flags.cpp @@ -30,7 +30,7 @@ DEFINE_int32( DEFINE_bool( velox_time_allocations, - true, + false, "Record time and volume for large allocation/free"); // Used in common/base/VeloxException.cpp