Skip to content

ci: pin build_base_venvs memory to prevent cold-cache OOM#18962

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
ci/build-base-venvs-oom
Jul 13, 2026
Merged

ci: pin build_base_venvs memory to prevent cold-cache OOM#18962
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
ci/build-base-venvs-oom

Conversation

@vlad-scherbich

@vlad-scherbich vlad-scherbich commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

build_base_venvs is OOMKilled for cold-ext_cache Python versions. Currently this happens for v3.15 only, which is new and has no warm cache. This was found while working on #17849.

Root cause

  • It sets no KUBERNETES_MEMORY_* and does not disable the VPA, so the autoscaler tunes the limit down to ~5GB, based on the cheap warm-cache history.
  • A cold version compiles everything at 12-way parallelism, which exceeds the approximated limit.

Changes

Pin CPU/memory and disable the VPA on build_base_venvs, matching what .build_base, test sdist already use for the same build targets:

KUBERNETES_CPU_REQUEST: '6'
KUBERNETES_MEMORY_REQUEST: '10Gi'
KUBERNETES_MEMORY_LIMIT: '10Gi'
DD_DISABLE_VPA: 'true'

Test plan

Screenshot 2026-07-09 at 4 25 46 PM

Additional Notes

  • Warm builds are unaffected.
  • The failing job logs also show the GitLab runner S3 cache returning 403 AccessDenied, so ext_cache restore fails on every run and forces cold compiles every time. That's a runner/ddbuild platform-side credential issue. Fixing this separately would restores warm-build speed.

build_base_venvs compiles every native extension (Rust _native, Cython,
IAST, profiling) at CMAKE_BUILD_PARALLEL_LEVEL=12. When a version's
ext_cache is cold -- e.g. a newly added Python version such as 3.15 --
the full 12-way parallel compile peaks well above the ~5Gi the VPA tunes
this job down to (observed "MemoryLimit changed from 6Gi to 5012971110"),
and the job is OOMKilled (exit 137) deterministically.

Pin CPU/memory and disable the VPA, matching the resource requests the
native package build jobs (.build_base, "test sdist") already use. This
keeps build parallelism intact and only affects cold-cache builds; warm
builds barely compile anything.
@vlad-scherbich
vlad-scherbich requested review from a team as code owners July 9, 2026 14:53
@vlad-scherbich
vlad-scherbich requested a review from P403n1x87 July 9, 2026 14:53
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

.gitlab/templates/build-base-venvs.yml                                  @DataDog/python-guild @DataDog/apm-core-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 9, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 4974 circular imports that already exist on the base branch and have not been changed by this PR.

Show existing cycles (showing 5 of 4974 shortest)
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.aiokafka -> ddtrace.internal.datastreams
ddtrace.internal.core -> ddtrace._trace.span -> ddtrace.internal.core
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.botocore -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kafka -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.google_cloud_pubsub -> ddtrace.internal.datastreams

To see all cycles, download the cycles-base.json and cycles-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/cycles.py compare cycles-base.json cycles-pr.json

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 8 tests - 8 passed on retry View in Datadog

🚧 3 tests that failed were ignored due to quarantine View in Datadog

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 88c0f8b | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Jul 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-13 19:23:26

Comparing candidate commit 88c0f8b in PR branch ci/build-base-venvs-oom with baseline commit cf59b87 in branch main.

Found 0 performance improvements and 6 performance regressions! Performance is the same for 616 metrics, 10 unstable metrics.

scenario:iastaspects-index_aspect

  • 🟥 execution_time [+10.399µs; +14.986µs] or [+8.058%; +11.612%]

scenario:iastaspects-ljust_aspect

  • 🟥 execution_time [+76.066µs; +84.065µs] or [+13.059%; +14.433%]

scenario:iastaspects-swapcase_aspect

  • 🟥 execution_time [+54.068µs; +61.367µs] or [+15.374%; +17.450%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+98.211µs; +106.091µs] or [+23.326%; +25.197%]

scenario:span-start

  • 🟥 execution_time [+1.259ms; +1.440ms] or [+7.948%; +9.088%]

scenario:tracer-small

  • 🟥 execution_time [+27.517µs; +30.661µs] or [+8.016%; +8.932%]

@vlad-scherbich vlad-scherbich added the changelog/no-changelog A changelog entry is not required for this PR. label Jul 9, 2026
@vlad-scherbich
vlad-scherbich requested a review from Copilot July 9, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GitLab CI build_base_venvs job to avoid cold-cache OOMKills by explicitly pinning Kubernetes CPU/memory requests/limits and disabling VPA tuning, aligning its runtime constraints with other native-build jobs in the pipeline.

Changes:

  • Add KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, and KUBERNETES_MEMORY_LIMIT to build_base_venvs.
  • Set DD_DISABLE_VPA to prevent VPA from clamping memory during cold-cache native extension builds.
  • Document the rationale inline in the job’s variables section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .gitlab/templates/build-base-venvs.yml
KowalskiThomas

This comment was marked as resolved.

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit bb53f37 into main Jul 13, 2026
1180 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the ci/build-base-venvs-oom branch July 13, 2026 20:51
vlad-scherbich added a commit that referenced this pull request Jul 15, 2026
## Description

`build_base_venvs` is OOMKilled for cold-`ext_cache` Python versions. Currently this happens for `v3.15` only, which is new and has no warm cache. This was found while working on #17849.

**Root cause**
- It sets **no** `KUBERNETES_MEMORY_*` and does not disable the VPA, so the autoscaler tunes the limit down to ~5GB, based on the cheap **warm-cache** history.
- A cold version compiles everything at 12-way parallelism, which exceeds the approximated limit.

### Changes

Pin CPU/memory and disable the VPA on `build_base_venvs`, matching what `.build_base`, `test sdist` already use for the same build targets:

```yaml
KUBERNETES_CPU_REQUEST: '6'
KUBERNETES_MEMORY_REQUEST: '10Gi'
KUBERNETES_MEMORY_LIMIT: '10Gi'
DD_DISABLE_VPA: 'true'
```

## Test plan

* [Next PR](#17849) passes [dd-gitlab/build_base_venvs: [3.15]](https://gitlab.ddbuild.io/datadog/apm-reliability/dd-trace-py/builds/1846141002)

<img width="494" height="472" alt="Screenshot 2026-07-09 at 4 25 46 PM" src="https://github.com/user-attachments/assets/c622de21-a232-4f23-a085-728ad4461d25" />
 

## Additional Notes

* Warm builds are unaffected.
* The failing job logs also show the GitLab **runner S3 cache returning 403 AccessDenied**, so `ext_cache` restore fails on every run and forces cold compiles every time. That's a runner/`ddbuild` platform-side credential issue. Fixing this separately would restores warm-build speed.

Co-authored-by: vlad.scherbich <vlad.scherbich@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants