Skip to content

Commit

Permalink
add mem limit floor of 350MB and set build jobs to cpu limit
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelone committed Nov 12, 2024
1 parent b670de4 commit 90d55da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions gantry/routes/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DEFAULT_CPU_LIMIT = 5
DEFAULT_MEM_LIMIT = 5 * 1_000_000_000
MEM_LIMIT_BUMP = 1.2
MEMORY_LIMIT_FLOOR = 3.5 * 1_000_000 # 350MB
EXPENSIVE_VARIANTS = {
"sycl",
"mpi",
Expand Down Expand Up @@ -44,7 +45,7 @@ async def predict(db: aiosqlite.Connection, spec: dict) -> dict:
"mem_request": DEFAULT_MEM_REQUEST,
"cpu_limit": DEFAULT_CPU_LIMIT,
"mem_limit": DEFAULT_MEM_LIMIT,
"build_jobs": DEFAULT_CPU_REQUEST,
"build_jobs": DEFAULT_CPU_LIMIT,
}
else:
# mapping of sample: [0] cpu_mean, [1] cpu_max, [2] mem_mean, [3] mem_max
Expand All @@ -56,7 +57,9 @@ async def predict(db: aiosqlite.Connection, spec: dict) -> dict:
"mem_limit": max(build[3] for build in sample) * MEM_LIMIT_BUMP,
}
# build jobs cannot be less than 1
predictions["build_jobs"] = max(1, round(predictions["cpu_request"]))
predictions["build_jobs"] = max(1, round(predictions["cpu_limit"]))
# enforce memory limit floor
predictions["mem_limit"] = max(predictions["mem_limit"], MEMORY_LIMIT_FLOOR)

# convert predictions to k8s friendly format
for k, v in predictions.items():
Expand Down
2 changes: 1 addition & 1 deletion gantry/tests/defs/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"KUBERNETES_CPU_REQUEST": "1000m",
"KUBERNETES_MEMORY_LIMIT": "5000M",
"KUBERNETES_MEMORY_REQUEST": "2000M",
"SPACK_BUILD_JOBS": 1,
"SPACK_BUILD_JOBS": 5,
},
}

0 comments on commit 90d55da

Please sign in to comment.