Skip to content

Commit

Permalink
Fix error in job dispatch's memory reporting
Browse files Browse the repository at this point in the history
Updated the test so that it will not work if process is counted number
of child processes times.
  • Loading branch information
JHolba authored and oyvindeide committed Sep 11, 2024
1 parent 5e9b0c4 commit a9c5eb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/_ert_forward_model_runner/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,6 @@ def _get_rss_and_oom_score_for_processtree(
else oom_score_child
)
with contextlib.suppress(NoSuchProcess, AccessDenied, ZombieProcess):
memory_rss += process.memory_info().rss
memory_rss += child.memory_info().rss

return (memory_rss, oom_score)
10 changes: 5 additions & 5 deletions tests/unit_tests/forward_model_runner/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def test_memory_usage_counts_grandchildren():
import sys
import time
counter = int(sys.argv[-1])
numbers = list(range(int(1e6)))
counter = int(sys.argv[-2])
numbers = list(range(int(sys.argv[-1])))
if counter > 0:
parent = os.fork()
if not parent:
os.execv(sys.argv[-2], [sys.argv[-2], str(counter - 1)])
os.execv(sys.argv[-3], [sys.argv[-3], str(counter - 1), str(int(1e7))])
time.sleep(1)""" # Too low sleep will make the test faster but flaky
)
)
Expand All @@ -69,7 +69,7 @@ def max_memory_per_subprocess_layer(layers: int) -> int:
job = Job(
{
"executable": executable,
"argList": [str(layers)],
"argList": [str(layers), str(int(1e6))],
},
0,
)
Expand All @@ -84,7 +84,7 @@ def max_memory_per_subprocess_layer(layers: int) -> int:
# comparing the memory used with different amounts of forks done.
# subtract a little bit (* 0.9) due to natural variance in memory used
# when running the program.
memory_per_numbers_list = sys.getsizeof(int(0)) * 1e6 * 0.9
memory_per_numbers_list = sys.getsizeof(int(0)) * 1e7 * 0.90

max_seens = [max_memory_per_subprocess_layer(layers) for layers in range(3)]
assert max_seens[0] + memory_per_numbers_list < max_seens[1]
Expand Down

0 comments on commit a9c5eb2

Please sign in to comment.