equinor/iterative_ensemble_smoother

Memory tests behave differently on one vs. several tests

Opened this issue ยท 1 comments

There seems to be some state or overhead when running multiple memray tests.

  • Running all three tests in one go reports high memory usage for the first one, lower for the remaining two tests
  • Running one at a time reports a relatively high memory usage for each test

Running all tests

pytest tests -k memory --memray 
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_without_overwrite at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 127.2MiB
	 ๐Ÿ“ Total allocations: 194
	 ๐Ÿ“Š Histogram of allocation sizes: |โ– โ–ˆ   โ– โ–ƒ|


Allocation results for tests/test_sies.py::test_memory_usage at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 63.8MiB
	 ๐Ÿ“ Total allocations: 237
	 ๐Ÿ“Š Histogram of allocation sizes: |โ–‚ โ–„   โ–… โ–ˆ|


Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_with_overwrite at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 54.8MiB
	 ๐Ÿ“ Total allocations: 156
	 ๐Ÿ“Š Histogram of allocation sizes: |โ–†   โ–…   โ–ˆ|

Running individually

pytest tests -k test_ESMDA_memory_usage_subspace_inversion_without_overwrite --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_without_overwrite at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 127.2MiB
	 ๐Ÿ“ Total allocations: 194
	 ๐Ÿ“Š Histogram of allocation sizes: |โ– โ–ˆ   โ– โ–ƒ|


pytest tests -k test_memory_usage --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_sies.py::test_memory_usage at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 127.8MiB
	 ๐Ÿ“ Total allocations: 255
	 ๐Ÿ“Š Histogram of allocation sizes: |โ–ˆ โ–… โ–ˆ โ–ƒ โ–ˆ|

pytest tests -k test_ESMDA_memory_usage_subspace_inversion_with_overwrite --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_with_overwrite at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 118.8MiB
	 ๐Ÿ“ Total allocations: 186
	 ๐Ÿ“Š Histogram of allocation sizes: |โ– โ–ˆ   โ– โ–ƒ|

There also seems to be a bit of state between runs:

<change the test>


(venv) > $ pytest tests --memray -k test_esmda_inversion_memory

==================================================================================== MEMRAY 
Allocation results for tests/test_esmda_inversion.py::test_esmda_inversion_memory at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 128.2MiB




(venv) > $ pytest tests --memray -k test_esmda_inversion_memory
==================================================================================== MEMRAY 
Allocation results for tests/test_esmda_inversion.py::test_esmda_inversion_memory at the high watermark

	 ๐Ÿ“ฆ Total memory allocated: 127.2MiB