Skip to content

fix(bazel): schedule Go links by memory to stop e2e build OOM kills - #57555

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
regis.desgroppes/golink-resource-set
Oct 5, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
regis.desgroppes/golink-resource-set

Conversation

@rdesgroppes

@rdesgroppes rdesgroppes commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Patch rules_go with bazel-contrib/rules_go#4727, which declares a 2048MB resource_set for GoLink instead of Bazel's 250MB default.

Motivation

go_e2e_test_binaries OOM kills resurfaced on main (#incident-61714) after #56683 bumped a constant in a package every e2e test depends on, forcing all test binaries to relink at once instead of hitting the remote cache, leading to either:

ERROR: Job failed (system failure): Error in container build: exit code: 137, reason: 'OOMKilled'
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

Bazel accounts 250MB per action and thus runs 16 of them at once, one per CPU granted since #56994, whereas a Go link peaks at up to 2490MB RSS, beyond the 32Gi memory limit (shared with Bazel's JVM, among others).

Describe how you validated your changes

//pkg/version:version_test builds with the patch applied and MODULE.bazel.lock stays unchanged.

### What does this PR do?
Patch rules_go with bazel-contrib/rules_go#4727, which declares a 2048MB
`resource_set` for `GoLink` instead of Bazel's 250MB default.
### Motivation
`go_e2e_test_binaries` OOM kills resurfaced on `main` (#incident-61714)
after #56683 bumped a constant in a package every e2e test depends on,
forcing all test binaries to relink instead of hitting the remote cache:
```
ERROR: Job failed (system failure): Error in container build: exit code: 137, reason: 'OOMKilled'
```
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108531979
```
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
```
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108458779
Bazel accounted 250MB per link and thus ran 16 of them at once, one per
CPU granted by #56994, whereas a link peaks at up to 2490MB RSS, beyond
the 32Gi memory limit #56994 also set.
### Describe how you validated your changes
`//pkg/version:version_test` builds with the patch applied and
`MODULE.bazel.lock` stays unchanged.
@rdesgroppes
rdesgroppes requested a review from a team as a code owner October 5, 2026 14:32
@rdesgroppes rdesgroppes added changelog/no-changelog No changelog entry needed qa/no-code-change No code change in Agent code requiring validation labels Oct 5, 2026
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/agent-build labels Oct 5, 2026
@github-actions github-actions Bot added the short review PR is simple enough to be reviewed quickly label Oct 5, 2026

@github-actions github-actions Bot 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.

AI review by Codex (OpenAI) - workflow run

Patch is correct. The patch adds a valid memory resource estimate to Go link actions and registers it in the existing rules_go override. No actionable issues found. Build validation was not run in this read-only environment.

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 62.72% (+4.21%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8c095b0 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 62356959:

Results for datadog-agent_7.86.0~devel.git.114.8c095b0.pipeline.142411670-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.86.0~devel.git.114.8c095b0.pipeline.142411670-1_amd64.deb:

No change detected

@dd-octo-sts

dd-octo-sts Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 6235695
📊 Static Quality Gates Dashboard
🔗 SQG Job

33 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
✅ agent_deb_amd64 759.575 MiB
✅ agent_deb_amd64_fips 692.620 MiB
✅ agent_heroku_amd64 318.819 MiB
✅ agent_msi 653.242 MiB
✅ agent_rpm_amd64 759.559 MiB
✅ agent_rpm_amd64_fips 692.604 MiB
✅ agent_rpm_arm64 730.154 MiB
✅ agent_rpm_arm64_fips 668.795 MiB
✅ agent_suse_amd64 759.559 MiB
✅ agent_suse_amd64_fips 692.604 MiB
✅ agent_suse_arm64 730.154 MiB
✅ agent_suse_arm64_fips 668.795 MiB
✅ docker_agent_amd64 815.781 MiB
✅ docker_agent_arm64 811.023 MiB
✅ docker_agent_jmx_amd64 1006.651 MiB
✅ docker_agent_jmx_arm64 990.672 MiB
✅ docker_cws_instrumentation_amd64 7.439 MiB
✅ docker_cws_instrumentation_arm64 6.877 MiB
✅ docker_dogstatsd_amd64 39.504 MiB
✅ docker_dogstatsd_arm64 37.566 MiB
✅ docker_host_profiler_amd64 308.483 MiB
✅ docker_host_profiler_arm64 319.621 MiB
✅ dogstatsd_deb_amd64 30.246 MiB
✅ dogstatsd_deb_arm64 28.243 MiB
✅ dogstatsd_rpm_amd64 30.246 MiB
✅ dogstatsd_suse_amd64 30.246 MiB
✅ iot_agent_deb_amd64 47.217 MiB
✅ iot_agent_deb_arm64 43.696 MiB
✅ iot_agent_deb_armhf 44.507 MiB
✅ iot_agent_rpm_amd64 47.218 MiB
✅ iot_agent_suse_amd64 47.217 MiB
✅ docker_cluster_agent_amd64 214.011 MiB
✅ docker_cluster_agent_arm64 226.887 MiB

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 71b78565-a2e9-4aa0-955b-847333a2b464

Baseline: 1791cb2
Comparison: 353a00a
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
➖ quality_gate_security_mean_fs_load memory utilization +0.74 [+0.70, +0.77] 1 Logs bounds checks dashboard
➖ quality_gate_private_action_runner memory utilization +0.27 [+0.14, +0.39] 1 Logs bounds checks dashboard
➖ quality_gate_idle memory utilization +0.22 [+0.18, +0.27] 1 Logs bounds checks dashboard
➖ python_openmetrics % cpu utilization +0.05 [-0.62, +0.71] 1 Logs bounds checks dashboard
➖ quality_gate_idle_all_features memory utilization +0.02 [-0.05, +0.10] 1 Logs bounds checks dashboard
➖ quality_gate_security_idle memory utilization -0.12 [-0.16, -0.08] 1 Logs bounds checks dashboard
➖ quality_gate_security_no_fs_load memory utilization -0.24 [-0.32, -0.17] 1 Logs bounds checks dashboard
➖ quality_gate_logs % cpu utilization -0.30 [-1.17, +0.57] 1 Logs bounds checks dashboard
➖ quality_gate_metrics_logs memory utilization -0.33 [-0.56, -0.10] 1 Logs bounds checks dashboard
➖ dsd_uds_client_drop_detector_cpu % cpu utilization -0.34 [-0.85, +0.16] 1 Logs
➖ dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization -0.74 [-0.96, -0.52] 1 Logs
➖ dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization -0.80 [-1.03, -0.56] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
✅ python_openmetrics checks_execution_time 10/10 71.58 ≤ 100 bounds checks dashboard
✅ python_openmetrics cpu_usage 10/10 1330.68 ≤ 1500 bounds checks dashboard
✅ python_openmetrics memory_usage 10/10 4.33GiB ≤ 4.75GiB bounds checks dashboard
✅ quality_gate_idle intake_connections 10/10 4 ≤ 5 bounds checks dashboard
✅ quality_gate_idle memory_usage 10/10 174.00MiB ≤ 181MiB bounds checks dashboard
✅ quality_gate_idle total_bytes_received 10/10 761.30KiB ≤ 819.20KiB bounds checks dashboard
✅ quality_gate_idle_all_features intake_connections 10/10 2 ≤ 5 bounds checks dashboard
✅ quality_gate_idle_all_features memory_usage 10/10 471.96MiB ≤ 542MiB bounds checks dashboard
✅ quality_gate_idle_all_features total_bytes_received 10/10 1.13MiB ≤ 1.25MiB bounds checks dashboard
✅ quality_gate_logs intake_connections 10/10 18 ≤ 40 bounds checks dashboard
✅ quality_gate_logs memory_usage 10/10 211.26MiB ≤ 228MiB bounds checks dashboard
✅ quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
✅ quality_gate_logs total_bytes_received 10/10 263.22MiB ≤ 292MiB bounds checks dashboard
✅ quality_gate_metrics_logs cpu_usage 10/10 376.79 ≤ 2000 bounds checks dashboard
✅ quality_gate_metrics_logs intake_connections 10/10 20 ≤ 40 bounds checks dashboard
✅ quality_gate_metrics_logs memory_usage 10/10 432.34MiB ≤ 455MiB bounds checks dashboard
✅ quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
✅ quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
✅ quality_gate_private_action_runner memory_usage 10/10 73.80MiB ≤ 77MiB bounds checks dashboard
✅ quality_gate_security_idle cpu_usage 10/10 29.52 ≤ 100 bounds checks dashboard
✅ quality_gate_security_idle memory_usage 10/10 329.23MiB ≤ 357MiB bounds checks dashboard
✅ quality_gate_security_mean_fs_load cpu_usage 10/10 62.08 ≤ 200 bounds checks dashboard
✅ quality_gate_security_mean_fs_load memory_usage 10/10 303.90MiB ≤ 337MiB bounds checks dashboard
✅ quality_gate_security_no_fs_load cpu_usage 10/10 23.52 ≤ 100 bounds checks dashboard
✅ quality_gate_security_no_fs_load memory_usage 10/10 315.16MiB ≤ 348MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

✅ Passed. All Quality Gates passed.

  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 353a00a into main Oct 5, 2026
322 of 330 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the regis.desgroppes/golink-resource-set branch October 5, 2026 16:28
@github-actions github-actions Bot added this to the 7.86.0 milestone Oct 5, 2026
github-actions Bot pushed a commit that referenced this pull request Oct 5, 2026
…57555)

### What does this PR do?
Patch `rules_go` with bazel-contrib/rules_go#4727, which declares a 2048MB `resource_set` for `GoLink` instead of Bazel's 250MB default.

### Motivation
`go_e2e_test_binaries` OOM kills resurfaced on `main` ([#incident-61714](https://dd.enterprise.slack.com/archives/C0C6V8J63B3)) after #56683 bumped a constant in a package every e2e test depends on, forcing all test binaries to relink at once instead of hitting the remote cache, leading to either:
- `OOMKilled` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108531979)):
```
ERROR: Job failed (system failure): Error in container build: exit code: 137, reason: 'OOMKilled'
```
- or `Segmentation fault` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108458779)):
```
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
```
Bazel accounts 250MB per action and thus runs 16 of them at once, one per CPU granted since #56994, whereas a Go link peaks at up to 2490MB RSS, beyond the 32Gi memory limit (shared with Bazel's JVM, among others).

### Describe how you validated your changes
`//pkg/version:version_test` builds with the patch applied and `MODULE.bazel.lock` stays unchanged.

Co-authored-by: regis.desgroppes <[email protected]> 353a00a
rdesgroppes added a commit that referenced this pull request Oct 8, 2026
### What does this PR do?
Book 6144 MiB for the `GoLink` action of the 9 non-`manual`
`dd_agent_go_test` unit test targets whose packages import the e2e
framework, through the `go_link` exec group's `resources:memory`.

6144 is the multiple of 1024 closest to their peak link RSS, measured
between 5826 MiB (lower bound) and 6241 MiB (upper bound) on Linux.

Document the pattern in `bazel/AGENTS.md`.

### Motivation
`bazel:test:windows-amd64:go` failed in the merge queue
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2121988398) with
5 unit test binaries failing to link and `client_test` timing out after
304s instead of passing in seconds:
```
runtime: VirtualAlloc of 1540096 bytes failed with errno=1455
fatal error: out of memory
```

Since #57555, `rules_go` is patched for `GoLink` to declare a flat 2048
MiB `resource_set`, which stopped the `go_e2e_test_binaries` OOM kills
on `main` but can't account for outliers.

Linking these unit tests peaks at about 30 times the on-disk footprint
of their binaries, which embed the e2e framework and weigh 195MiB to
227MiB.

On 32GiB `c5.4xlarge` runners, Bazel thus runs enough of these links at
once to exhaust the commit limit.

### Describe how you validated your changes
`bazel aquery` shows `resources:memory=6144` on the `GoLink` actions of
the 9 targets only, not on their compile or test actions.

With `--local_resources=memory=13000`, a Bazel profile of their 9 links
shows at most 2 running concurrently instead of 6.

### Additional Notes
Bazel honors `resources:*` exec properties in local scheduling since
9.2.0 (bazelbuild/bazel#29284), overriding the action's `resource_set`.
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Oct 9, 2026
…57863)

### What does this PR do?
Tell Bazel to account for 6144 MiB (RSS) for the `GoLink` action of the 9 `dd_agent_go_test` unit test targets whose packages import the e2e framework, through a `go_link:enormous` tag that the macro translates into the `go_link` exec group's `resources:memory`.

6144 is the multiple of 1024 closest to their peak link RSS, measured between 5826 MiB (lower bound) and 6241 MiB (upper bound) on Linux.

Document the pattern in `bazel/AGENTS.md`.

### Motivation
`bazel:test:windows-amd64:go` [failed in the merge queue](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2121988398) with 5 unit test binaries failing to link and `client_test` timing out after 304s instead of passing in seconds:
```
runtime: VirtualAlloc of 1540096 bytes failed with errno=1455
fatal error: out of memory
```
... and this was [not an isolated case](https://app.datadoghq.com/logs?query=service%3Agitlab-ci%20%40ci.pipeline.name%3A%22DataDog%2Fdatadog-agent%22%20%22VirtualAlloc%22&agg_m=count&agg_m_source=base&agg_t=count&clustering_pattern_field_path=message&cols=host%2Cservice%2Cci.node.name&index=ci-app-pipeline-logs-gitlab-datadog-agent&messageDisplay=inline&refresh_mode=sliding&storage=hot&stream_sort=time%2Cdesc&viz=stream&from_ts=1790877978397&to_ts=1791482778397).

Since #57555, `rules_go` is patched for `GoLink` to declare a flat 2048 MiB `resource_set` (in lieu of only 250), which stopped the `go_e2e_test_binaries` OOM kills on `main` but can't account for outliers.

Linking these unit tests indeed peaks at about 30 times the on-disk footprint of their binaries, which embed the e2e framework and weigh 195MiB to 227MiB.

On the 32GiB `c5.4xlarge` runners used by Windows jobs, for instance, Bazel thus runs enough of these links at once to exhaust the commit limit.

### Describe how you validated your changes
`bazel aquery` shows `resources:memory=6144` on the `GoLink` actions of the 9 targets only, not on their compile or test actions.

With `--local_resources=memory=13000`, a Bazel profile of their 9 links shows at most 2 running concurrently instead of 6.

### Additional Notes
Bazel honors `resources:*` exec properties in local scheduling since 9.2.0 (bazelbuild/bazel#29284), overriding the action's `resource_set`.


Co-authored-by: regis.desgroppes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR qa/no-code-change No code change in Agent code requiring validation short review PR is simple enough to be reviewed quickly team/agent-build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants