Print compositor execution statistics when in background mode

This will print memory usage, mapped memory usage, memory peak,
compositing tree name and number of finished tiles to stdout
when blender is rendering in background mode.

This makes compositor a less blackbox and should help trouble
shooting issues happening during 4K ToS project.
This commit is contained in:
Sergey Sharybin 2013-03-12 14:28:52 +00:00
parent 96412b711e
commit 984bd7ffa8
2 changed files with 32 additions and 0 deletions

@ -40,6 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BKE_global.h"
#include "PIL_time.h"
#include "WM_api.h"
#include "WM_types.h"
@ -410,6 +411,29 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem
return result;
}
void ExecutionGroup::printBackgroundStats(void)
{
uintptr_t mem_in_use, mmap_in_use, peak_memory;
float megs_used_memory, mmap_used_memory, megs_peak_memory;
mem_in_use = MEM_get_memory_in_use();
mmap_in_use = MEM_get_mapped_memory_in_use();
peak_memory = MEM_get_peak_memory();
megs_used_memory = (mem_in_use - mmap_in_use) / (1024.0 * 1024.0);
mmap_used_memory = (mmap_in_use) / (1024.0 * 1024.0);
megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
fprintf(stdout, "Mem:%.2fM (%.2fM, Peak %.2fM) ",
megs_used_memory, mmap_used_memory, megs_peak_memory);
printf("| Tree %s, Tile %d-%d ", this->m_bTree->id.name + 2,
this->m_chunksFinished, this->m_numberOfChunks);
fputc('\n', stdout);
fflush(stdout);
}
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
@ -433,6 +457,9 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
float progress = this->m_chunksFinished;
progress /= this->m_numberOfChunks;
this->m_bTree->progress(this->m_bTree->prh, progress);
if (G.background)
printBackgroundStats();
}
}

@ -341,6 +341,11 @@ public:
* @see determineChunkRect
*/
MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
/**
* @brief print execution statistics to stdout when running in a background mode
*/
void printBackgroundStats(void);
/**
* @brief after a chunk is executed the needed resources can be freed or unlocked.