gem/oq-engine — pull request #1167 by micheles (2013-05-05 15:09:45+00:00)
Title: Improved the memory profiling

Due to the critical bug https://bugs.launchpad.net/oq-engine/+bug/1175941 the importance of profiling the memory management of blocks of code has raised considerably. The default of the EnginePerformanceMonitor has been changed to measure the memory occupation; moreover the way the memory was measured has changed and it is now drastically faster, so that the overhead of using the profiler is normally negligible.I took inspiration from the memory_profiler module and now

with EnginePerformanceMonitor(...):
block

measures the RSS memory at the beginning and at the end of the block and saves the difference. The memory is measured in bytes and can be negative if in that block of code the OS has freed some memory. I have also changed the performance_view so that it displays the maximum memory occupation during a given operation.