Repository navigation
fix(bazel): schedule heavy Go unit test links by memory to stop OOMs - #57863
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is correct. The nine test targets forward the link-specific memory reservation through the existing macro, and the pinned Bazel version supports local resource overrides. No actionable issues found. Buildifier and Bazel execution checks were unavailable in this read-only environment.
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is correct. The changes forward link-specific memory requirements through the existing test macro, and the pinned Bazel 9.3.0 supports the documented scheduling behavior. No actionable issues found. Buildifier and Bazel execution were not verified in the read-only environment.
Files inventory check summaryFile checks results against ancestor 33393f61: Results for datadog-agent_7.86.0~devel.git.297.ba20168.pipeline.143564159-1_amd64.deb:No change detected Results for datadog-iot-agent_7.86.0~devel.git.297.ba20168.pipeline.143564159-1_amd64.deb:No change detected |
Static quality checks✅ Please find below the results from static quality gates 33 successful checks with minimal change (< 2 KiB)
|
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: 7cc1c82 Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | quality_gate_private_action_runner | memory utilization | +0.65 | [+0.53, +0.78] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_mean_fs_load | memory utilization | +0.50 | [+0.47, +0.54] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_metrics_logs | memory utilization | +0.36 | [+0.13, +0.58] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | +0.30 | [+0.26, +0.34] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle | memory utilization | -0.05 | [-0.09, -0.01] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle_all_features | memory utilization | -0.16 | [-0.24, -0.09] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_no_fs_load | memory utilization | -0.20 | [-0.27, -0.13] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.25 | [-0.92, +0.42] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | -0.68 | [-0.89, -0.47] | 1 | Logs |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | -1.01 | [-1.50, -0.53] | 1 | Logs |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | -2.19 | [-2.43, -1.96] | 1 | Logs |
| ➖ | quality_gate_logs | % cpu utilization | -3.17 | [-4.04, -2.29] | 1 | Logs bounds checks dashboard |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 80.11 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1337.96 ≤ 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 | 176.56MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 759.01KiB ≤ 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.83MiB ≤ 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 | 17 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 218.24MiB ≤ 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.87MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 377.85 ≤ 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 | 423.89MiB ≤ 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.95GiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 75.41MiB ≤ 77MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 29.33 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 329.80MiB ≤ 357MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 64.04 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 307.88MiB ≤ 337MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 23.14 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 318.96MiB ≤ 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:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
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.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates 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_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, 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_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 total_bytes_received: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_private_action_runner, bounds check memory_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_security_mean_fs_load, bounds check cpu_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 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_metrics_logs, bounds check cpu_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.
- 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.
clarkb7
left a comment
There was a problem hiding this comment.
the number of parallel go build processes has always gone hand-in-hand with the runner VM memory and the container memory limits. could be worth revisiting if bazel handles parallel builds differently than our invoke tasks did before.
@clarkb7 in fact, Bazel manages resources pretty well, both CPUs and RAM visible from within the container, by applying a pretty conservative heuristic:
Where that doesn't fly:
Bazel is agnostic to Go, but one of the most demanding actions we have in the whole project is precisely
That's why, until we ( Not ideal, I know, but please bear with us, we'll figure something out. |
### 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`.
> This is repeated widely, and probably likely to change in bulk since > it has a specific constant (3/4 of 8k, a number branded in my memory > forever because of past work). > > We should turn indirect this through a human readable meaning, like > "large_mem", and have the macro add the exec_properties. We don't even > need a new attribute, we can make it a `tag`. That way we can even > select those tests in or out of a larger test run based on the tag. Replace the 9 `exec_properties` with a `go_link:enormous` tag, which `dd_agent_go_test` translates into `go_link.resources:memory`, so the 6144 constant only lives in the macro. The name scopes the tag to the `go_link` exec group, the only one it books memory for, and borrows the top word of Bazel's test `size` scale, which 6144 still exceeds. Its colon form follows Bazel's parameterized tags like `cpu:N`, without matching any prefix Bazel interprets. > Isn't non-manual is irrelevant? That is, shouldn't all tests using e2e > framework need more memory - it's just that some blow past a limit so > that we bump them? Drop "non-`manual`" from `bazel/AGENTS.md`, which now says to tag the tests whose links fail.
6f68ad2 to
ba20168
Compare
ce3e642
into
main
### What does this PR do? Register `kubernetes:helm.sh/v3:Release` and `kubernetes:yaml/v2:ConfigGroup` through local `resources/helm` and `resources/yaml` packages, instead of the pulumi-kubernetes SDK's `helm/v3` and `yaml` packages, which import 71 to 72 of its 86 packages. Move every `yaml.ConfigGroup` and `yaml.ConfigFile` to the provider-side `yaml/v2` `ConfigGroup`: - `kwok` turns its transformations into Pulumi transforms of the group's children, keeping its static manifest URLs, - `dda` applies its transformations before passing its object, as `yaml/v2` names children after their metadata, before any transform. ### Motivation Linking the 14 non-`manual` unit tests importing those packages peaks at 4.8 GiB to 6.1 GiB RSS, which ran Windows runners out of commit memory (#57863). ### Describe how you validated your changes No `go_test`, `manual` ones included, depends on `helm/v3`, `yaml` or `yaml/v2` anymore, and the link peaks of affected tests drop by 41% to 56%, e.g. `environments_test` from 6241 MiB to 3689 MiB. Pulumi mocks confirmed the registered types and inputs, and the decoding of `Release.Status`. ### Additional Notes Resources applied through `yaml/v2` get new URNs, hence a one-time replacement on existing stacks.
### What does this PR do? Register `kubernetes:helm.sh/v3:Release` and `kubernetes:yaml/v2:ConfigGroup` through local `resources/helm` and `resources/yaml` packages, instead of the pulumi-kubernetes SDK's `helm/v3` and `yaml` packages, which import 71 to 72 of its 86 packages. Move every `yaml.ConfigGroup` and `yaml.ConfigFile` to the provider-side `yaml/v2` `ConfigGroup`: - `kwok` turns its transformations into Pulumi transforms of the group's children, keeping its static manifest URLs, - `dda` applies its transformations before passing its object, as `yaml/v2` names children after their metadata, before any transform. ### Motivation Linking the 14 non-`manual` unit tests importing those packages peaks at 4.8 GiB to 6.1 GiB RSS, which ran Windows runners out of commit memory (#57863). ### Describe how you validated your changes No `go_test`, `manual` ones included, depends on `helm/v3`, `yaml` or `yaml/v2` anymore, and the link peaks of affected tests drop by 41% to 56%, e.g. `environments_test` from 6241 MiB to 3689 MiB. Pulumi mocks confirmed the registered types and inputs, and the decoding of `Release.Status`. ### Additional Notes Resources applied through `yaml/v2` get new URNs, hence a one-time replacement on existing stacks.
…#58007) ### What does this PR do? Tag 5 more unit test targets `go_link:enormous`: `system-probe_test`, `ibm_mq_test`, `microvms_test`, `components/datadog/agent:agent_test` and `operator_test`. Their links peak at 4885 MiB to 6087 MiB on Linux, as they share the trait of the 9 targets tagged by #57863: linking most of the pulumi-kubernetes SDK (72 of its 86 packages) through its `yaml` package, which its `helm/v3` package imports. Reword the `bazel/AGENTS.md` note and the macro comment accordingly, the e2e framework only being a proxy for that trait. ### Motivation `bazel:test:windows-amd64:go` failed with `errno=1455` (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2127221742) on a branch predating #57863, with `microvms_test` failing to link next to 4 of the targets it tagged. Among non-`manual` `go_test` targets, only the 14 linking most of the pulumi-kubernetes SDK peak above 4 GiB, the next one being `run_test_otlp` at 3904 MiB, while neither their archive count nor their source file count predicts it. ### Describe how you validated your changes The following `bazel cquery` returns nothing, on Linux as on Windows, where `system-probe_test` doesn't build: ``` kind("go_test", rdeps(//..., @com_github_pulumi_pulumi_kubernetes_sdk_v4//go/kubernetes/yaml)) except attr(tags, manual, //...) except attr(tags, "go_link:enormous", //...) ``` ### Additional Notes I'm considering 2 follow-ups: - a CI job enforcing the tag through that query, like `bazel:query-missing-manual-tags` does for `manual`, - a `rules_go` contribution estimating `GoLink` memory at analysis time instead of declaring a flat `resource_set` (bazel-contrib/rules_go#4726), as the callback must be top-level but `emit_link` may pick among several of them based on the linked archives. Co-authored-by: regis.desgroppes <[email protected]>
What does this PR do?
Tell Bazel to account for 6144 MiB (RSS) for the
GoLinkaction of the 9dd_agent_go_testunit test targets whose packages import the e2e framework, through ago_link:enormoustag that the macro translates into thego_linkexec group'sresources: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:gofailed in the merge queue with 5 unit test binaries failing to link andclient_testtiming out after 304s instead of passing in seconds:... and this was not an isolated case.
Since #57555,
rules_gois patched forGoLinkto declare a flat 2048 MiBresource_set(in lieu of only 250), which stopped thego_e2e_test_binariesOOM kills onmainbut 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.4xlargerunners 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 aqueryshowsresources:memory=6144on theGoLinkactions 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'sresource_set.