Move the computation of total unused allocated memory into FastAlloc.cpp

This commit is contained in:
A.J. Beamon 2018-06-20 14:33:59 -07:00
parent 4e4bc19c73
commit afdd992fca
3 changed files with 18 additions and 12 deletions

View File

@ -410,6 +410,22 @@ void releaseAllThreadMagazines() {
FastAllocator<4096>::releaseThreadMagazines();
}
int64_t getTotalUnusedAllocatedMemory() {
int64_t unusedMemory = 0;
unusedMemory += FastAllocator<16>::getMemoryUnused();
unusedMemory += FastAllocator<32>::getMemoryUnused();
unusedMemory += FastAllocator<64>::getMemoryUnused();
unusedMemory += FastAllocator<128>::getMemoryUnused();
unusedMemory += FastAllocator<256>::getMemoryUnused();
unusedMemory += FastAllocator<512>::getMemoryUnused();
unusedMemory += FastAllocator<1024>::getMemoryUnused();
unusedMemory += FastAllocator<2048>::getMemoryUnused();
unusedMemory += FastAllocator<4096>::getMemoryUnused();
return unusedMemory;
}
template class FastAllocator<16>;
template class FastAllocator<32>;
template class FastAllocator<64>;

View File

@ -149,6 +149,7 @@ private:
};
void releaseAllThreadMagazines();
int64_t getTotalUnusedAllocatedMemory();
void setFastAllocatorThreadInitFunction( void (*)() ); // The given function will be called at least once in each thread that allocates from a FastAllocator. Currently just one such function is tracked.
template<int X>

View File

@ -51,17 +51,6 @@ SystemStatistics customSystemMonitor(std::string eventName, StatisticsState *sta
NetworkData netData;
netData.init();
if (!DEBUG_DETERMINISM && currentStats.initialized) {
int64_t unusedMemory = 0;
unusedMemory += FastAllocator<16>::getMemoryUnused();
unusedMemory += FastAllocator<32>::getMemoryUnused();
unusedMemory += FastAllocator<64>::getMemoryUnused();
unusedMemory += FastAllocator<128>::getMemoryUnused();
unusedMemory += FastAllocator<256>::getMemoryUnused();
unusedMemory += FastAllocator<512>::getMemoryUnused();
unusedMemory += FastAllocator<1024>::getMemoryUnused();
unusedMemory += FastAllocator<2048>::getMemoryUnused();
unusedMemory += FastAllocator<4096>::getMemoryUnused();
{
TraceEvent e(eventName.c_str());
e
@ -71,7 +60,7 @@ SystemStatistics customSystemMonitor(std::string eventName, StatisticsState *sta
.detail("UptimeSeconds", now() - machineState.monitorStartTime)
.detail("Memory", currentStats.processMemory)
.detail("ResidentMemory", currentStats.processResidentMemory)
.detail("UnusedAllocatedMemory", unusedMemory)
.detail("UnusedAllocatedMemory", getTotalUnusedAllocatedMemory())
.detail("MbpsSent", ((netData.bytesSent - statState->networkState.bytesSent) * 8e-6) / currentStats.elapsed)
.detail("MbpsReceived", ((netData.bytesReceived - statState->networkState.bytesReceived) * 8e-6) / currentStats.elapsed)
.detail("DiskTotalBytes", currentStats.processDiskTotalBytes)