Skip to content

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

Open
vlad-scherbich wants to merge 2 commits into
mainfrom
ci/build-base-venvs-oom
Open

ci: pin build_base_venvs memory to prevent cold-cache OOM#18962
vlad-scherbich wants to merge 2 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

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.google_cloud_pubsub -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.botocore -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kombu -> ddtrace.internal.datastreams
ddtrace.internal.core -> ddtrace._trace.span -> ddtrace.internal.core
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.aiokafka -> 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

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 9 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741491-d2b8243-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

View all 9 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 7 jobs - 7 passed on retry View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9ff9307 | 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-09 21:10:05

Comparing candidate commit 9ff9307 in PR branch ci/build-base-venvs-oom with baseline commit 857c18a in branch main.

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

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+95.377µs; +104.867µs] or [+22.517%; +24.757%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+13.030µs; +20.937µs] or [+8.570%; +13.770%]

scenario:span-start

  • 🟥 execution_time [+1.221ms; +1.373ms] or [+7.860%; +8.838%]

@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 KowalskiThomas 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.

LGTM.

Comment on lines +14 to +18
# Pin resources and disable the VPA. This job compiles every native
# extension in parallel (CMAKE_BUILD_PARALLEL_LEVEL=12, set above) whenever
# the ext_cache is cold (e.g. a newly added Python version), which peaks
# well above the ~5Gi the VPA otherwise tunes it down to and gets OOMKilled.
# Matches the resource requests used by the native package build jobs.

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.

Are those requests defined somewhere within dd-trace-py? If so, could you add a comment there to make sure we also update this file when they're updated?

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