Skip to content

Commit

Permalink
Fix flaky memory test
Browse files Browse the repository at this point in the history
Register only the memory allocations of the function we are trying to
test.
  • Loading branch information
JHolba committed Sep 27, 2024
1 parent 321767c commit 3bc3a88
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/ert/performance_tests/test_memory_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path
from typing import List

import memray
import numpy as np
import py
import pytest
Expand Down Expand Up @@ -38,8 +39,6 @@ def poly_template(monkeypatch):
yield folder


@pytest.mark.flaky(reruns=5)
@pytest.mark.limit_memory("130 MB")
@pytest.mark.integration_test
def test_memory_smoothing(poly_template):
ert_config = ErtConfig.from_file("poly.ert")
Expand All @@ -54,12 +53,16 @@ def test_memory_smoothing(poly_template):
name="posterior",
prior_ensemble=prior_ens,
)
smoother_update(
prior_ens,
posterior_ens,
list(ert_config.observations.keys()),
list(ert_config.ensemble_config.parameters),
)
with memray.Tracker(poly_template / "memray.bin"):
smoother_update(
prior_ens,
posterior_ens,
list(ert_config.observations.keys()),
list(ert_config.ensemble_config.parameters),
)

stats = memray._memray.compute_statistics(str(poly_template / "memray.bin"))
assert stats.peak_memory_allocated < 1024**2 * 130


def fill_storage_with_data(poly_template: Path, ert_config: ErtConfig) -> None:
Expand Down

0 comments on commit 3bc3a88

Please sign in to comment.