Skip to content

Commit

Permalink
return SPACK_BUILD_JOBS with resource allocation to control the build…
Browse files Browse the repository at this point in the history
… system

`SPACK_BUILD_JOBS=max(1, cpu_request)`
  • Loading branch information
cmelone committed Oct 23, 2024
1 parent b865ee4 commit 95208b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gantry/routes/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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,
}
else:
# mapping of sample: [0] cpu_mean, [1] cpu_max, [2] mem_mean, [3] mem_max
Expand All @@ -54,6 +55,8 @@ async def predict(db: aiosqlite.Connection, spec: dict) -> dict:
"cpu_limit": sum([build[1] for build in sample]) / n,
"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"]))

if strategy == "ensure_higher":
ensure_higher_pred(predictions, spec["pkg_name"])
Expand All @@ -71,6 +74,8 @@ async def predict(db: aiosqlite.Connection, spec: dict) -> dict:
"KUBERNETES_MEMORY_REQUEST": predictions["mem_request"],
"KUBERNETES_CPU_LIMIT": predictions["cpu_limit"],
"KUBERNETES_MEMORY_LIMIT": predictions["mem_limit"],
"SPACK_BUILD_JOBS": predictions["build_jobs"],
"CI_JOB_SIZE": "custom",
},
}

Expand Down
4 changes: 4 additions & 0 deletions gantry/tests/defs/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@
# calculated by running the baseline prediction algorithm on the sample data in gantry/tests/sql/insert_prediction.sql
NORMAL_PREDICTION = {
"variables": {
"CI_JOB_SIZE": "custom",
"KUBERNETES_CPU_LIMIT": "12001m",
"KUBERNETES_CPU_REQUEST": "11779m",
"KUBERNETES_MEMORY_LIMIT": "49424M",
"KUBERNETES_MEMORY_REQUEST": "9577M",
"SPACK_BUILD_JOBS": 12,
},
}

# this is what will get returned when there are no samples in the database
# that match what the client wants
DEFAULT_PREDICTION = {
"variables": {
"CI_JOB_SIZE": "custom",
"KUBERNETES_CPU_LIMIT": "5000m",
"KUBERNETES_CPU_REQUEST": "1000m",
"KUBERNETES_MEMORY_LIMIT": "5000M",
"KUBERNETES_MEMORY_REQUEST": "2000M",
"SPACK_BUILD_JOBS": 1,
},
}

0 comments on commit 95208b0

Please sign in to comment.