Skip to content

Commit

Permalink
Mute marginal cpu overspending
Browse files Browse the repository at this point in the history
There exists logs that a user has overspent with a factor of 1.0. This is not very
interesting, so skip logging anything that we don't find significant.
  • Loading branch information
berland committed Dec 16, 2024
1 parent 15efe41 commit fce478b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ert/ensemble_evaluator/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def _get_ens_id(source: str) -> str:
def detect_overspent_cpu(num_cpu: int, real_id: str, fm_step: FMStepSnapshot) -> str:
"""Produces a message warning about misconfiguration of NUM_CPU if
so is detected. Returns an empty string if everything is ok."""
allowed_overspending = 1.05
now = datetime.datetime.now()
duration = (
(fm_step.get(ids.END_TIME) or now) - (fm_step.get(ids.START_TIME) or now)
Expand All @@ -474,7 +475,7 @@ def detect_overspent_cpu(num_cpu: int, real_id: str, fm_step: FMStepSnapshot) ->
return ""
cpu_seconds = fm_step.get(ids.CPU_SECONDS) or 0.0
parallelization_obtained = cpu_seconds / duration
if parallelization_obtained > num_cpu:
if parallelization_obtained > num_cpu * allowed_overspending:
return (
f"Misconfigured NUM_CPU, forward model step '{fm_step.get(ids.NAME)}' for "
f"realization {real_id} spent {cpu_seconds} cpu seconds "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ async def test_ensure_multi_level_events_in_order(evaluator_to_use):
@given(
num_cpu=st.integers(min_value=1, max_value=64),
start=st.datetimes(),
duration=st.integers(min_value=-1, max_value=10000),
cpu_seconds=st.floats(min_value=0),
duration=st.integers(min_value=-1, max_value=1000),
cpu_seconds=st.floats(min_value=0, max_value=2000),
)
def test_overspent_cpu_is_logged(
num_cpu: int,
Expand All @@ -554,7 +554,7 @@ def test_overspent_cpu_is_logged(
cpu_seconds=cpu_seconds,
),
)
if duration > 0 and cpu_seconds / duration > num_cpu:
if duration > 0 and cpu_seconds / duration > num_cpu * 1.05:
assert "Misconfigured NUM_CPU" in message
else:
assert "NUM_CPU" not in message

0 comments on commit fce478b

Please sign in to comment.