lvs logging of memory usage

edited October 2023 in Verification

Hello,
From the klayout github repo, I downloaded klayout/testdata/lvs/inv.oas, klayout/testdata/lvs/inv.cir, and klayout/testdata/lvs/inv.lvs

Then I added the following lines to inv.lvs so it would create a log file of execution time and memory usage:

log_file("inv_lvs_log.txt")
verbose(true)
profile

To keep the attached image reasonably brief, it shows just a few representative lines from the log file that was created, but these lines are sufficient to support my point. My interpretation of the results is that the job required a "baseline" memory of 1359 MB, but line 39 of inv.lvs required an additional 147 MB, increasing the total to 1503 MB. In my version of inv.lvs (because I added lines for logging), line 39 is the boolean operation calculating the intersection of active & nwell. There are other similar boolean operations in inv.lvs, so it puzzles me that only the (active & nwell) intersection calculation would require an additional large block of memory. Can you explain?

Comments

  • edited October 2023

    The numbers reported are only the deltas of the process memory size - the actual memory used is an entirely different matter. Memory can be allocated temporarily and then freed again without returning it to the operating system. So the difference you observe only reflects the memory allocated but not necessarily used. Subsequent steps may not report any memory adder at all as they are happy with the usable memory chunks that have already been allocated.

    The details depend on the OS type, the heap implementation, order of allocation and effects like memory fragmentation. The C++ runtime may pre-allocate memory or there is something else going on inside the script engine which is beyond the application control.

    In general, using a tiny sample like the one you picked, does not give you anything meaningful. In order to measure and optimize memory footprint or performance, you'd need a sample that consumes memory significantly above that level - in the order of GB and several seconds of execution time.

    Matthias

  • Thank you, that's very helpful!

Sign In or Register to comment.