Export memory fragmentation in memstats.

PiperOrigin-RevId: 306580752
Change-Id: I68e733c099e93957eb1ccb728077563f0c1b3d2d
This commit is contained in:
A. Unique TensorFlower 2020-04-14 22:15:43 -07:00 committed by TensorFlower Gardener
parent e22095ef16
commit 7ba5af361b
5 changed files with 32 additions and 14 deletions

View File

@ -69,6 +69,7 @@ absl::optional<AllocatorStats> XlaDeviceAllocator::GetStats() {
tf_stats.bytes_reserved = se_stats->bytes_reserved; tf_stats.bytes_reserved = se_stats->bytes_reserved;
tf_stats.peak_bytes_reserved = se_stats->peak_bytes_reserved; tf_stats.peak_bytes_reserved = se_stats->peak_bytes_reserved;
tf_stats.bytes_reservable_limit = se_stats->bytes_reservable_limit; tf_stats.bytes_reservable_limit = se_stats->bytes_reservable_limit;
tf_stats.largest_free_block_bytes = se_stats->largest_free_block_bytes;
return tf_stats; return tf_stats;
} }

View File

@ -31,16 +31,22 @@ thread_local MemoryDebugAnnotation ScopedMemoryDebugAnnotation::annotation_;
string AllocatorStats::DebugString() const { string AllocatorStats::DebugString() const {
return strings::Printf( return strings::Printf(
"Limit: %20lld\n" "Limit: %20lld\n"
"InUse: %20lld\n" "InUse: %20lld\n"
"MaxInUse: %20lld\n" "MaxInUse: %20lld\n"
"NumAllocs: %20lld\n" "NumAllocs: %20lld\n"
"MaxAllocSize: %20lld\n", "MaxAllocSize: %20lld\n"
"Reserved: %20lld\n"
"PeakReserved: %20lld\n"
"LargestFreeBlock: %20lld\n",
static_cast<long long>(this->bytes_limit ? *this->bytes_limit : 0), static_cast<long long>(this->bytes_limit ? *this->bytes_limit : 0),
static_cast<long long>(this->bytes_in_use), static_cast<long long>(this->bytes_in_use),
static_cast<long long>(this->peak_bytes_in_use), static_cast<long long>(this->peak_bytes_in_use),
static_cast<long long>(this->num_allocs), static_cast<long long>(this->num_allocs),
static_cast<long long>(this->largest_alloc_size)); static_cast<long long>(this->largest_alloc_size),
static_cast<long long>(this->bytes_reserved),
static_cast<long long>(this->peak_bytes_reserved),
static_cast<long long>(this->largest_free_block_bytes));
} }
constexpr size_t Allocator::kAllocatorAlignment; constexpr size_t Allocator::kAllocatorAlignment;

View File

@ -160,13 +160,16 @@ struct AllocatorStats {
// if such a limit is known. // if such a limit is known.
absl::optional<int64> bytes_reservable_limit; absl::optional<int64> bytes_reservable_limit;
int64 largest_free_block_bytes; // Largest free block's size in heap.
AllocatorStats() AllocatorStats()
: num_allocs(0), : num_allocs(0),
bytes_in_use(0), bytes_in_use(0),
peak_bytes_in_use(0), peak_bytes_in_use(0),
largest_alloc_size(0), largest_alloc_size(0),
bytes_reserved(0), bytes_reserved(0),
peak_bytes_reserved(0) {} peak_bytes_reserved(0),
largest_free_block_bytes(0) {}
std::string DebugString() const; std::string DebugString() const;
}; };

View File

@ -20,13 +20,18 @@ namespace stream_executor {
std::string AllocatorStats::DebugString() const { std::string AllocatorStats::DebugString() const {
return absl::StrFormat( return absl::StrFormat(
"Limit: %20lld\n" "Limit: %20lld\n"
"InUse: %20lld\n" "InUse: %20lld\n"
"MaxInUse: %20lld\n" "MaxInUse: %20lld\n"
"NumAllocs: %20lld\n" "NumAllocs: %20lld\n"
"MaxAllocSize: %20lld\n", "MaxAllocSize: %20lld\n"
"Reserved: %20lld\n"
"PeakReserved: %20lld\n"
"LargestFreeBlock: %20lld\n",
this->bytes_limit ? *this->bytes_limit : 0, this->bytes_in_use, this->bytes_limit ? *this->bytes_limit : 0, this->bytes_in_use,
this->peak_bytes_in_use, this->num_allocs, this->largest_alloc_size); this->peak_bytes_in_use, this->num_allocs, this->largest_alloc_size,
this->bytes_reserved, this->peak_bytes_reserved,
this->largest_free_block_bytes);
} }
} // namespace stream_executor } // namespace stream_executor

View File

@ -43,13 +43,16 @@ struct AllocatorStats {
// if such a limit is known. // if such a limit is known.
absl::optional<int64> bytes_reservable_limit; absl::optional<int64> bytes_reservable_limit;
int64 largest_free_block_bytes; // Largest free block's size in heap.
AllocatorStats() AllocatorStats()
: num_allocs(0), : num_allocs(0),
bytes_in_use(0), bytes_in_use(0),
peak_bytes_in_use(0), peak_bytes_in_use(0),
largest_alloc_size(0), largest_alloc_size(0),
bytes_reserved(0), bytes_reserved(0),
peak_bytes_reserved(0) {} peak_bytes_reserved(0),
largest_free_block_bytes(0) {}
std::string DebugString() const; std::string DebugString() const;
}; };