Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ fuzz/artifacts/
fuzz/coverage/
fuzz/corpus/
heaptrack.*
# Logs that the macOS integration jobs write into the checkout.
integration-logs/
16 changes: 15 additions & 1 deletion .gitlab/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,18 @@ test-integration-linux-amd64:
junit: $PANORAMIC_LOG_DIR/panoramic.xml
paths:
- $PANORAMIC_LOG_DIR/
- target/cargo-timings/
when: always
variables:
RUNNER_SCRIPT_TIMEOUT: 40m
RUNNER_AFTER_SCRIPT_TIMEOUT: 5m
PANORAMIC_LOG_DIR: integration-logs/${CI_JOB_ID}
# Write cargo timing reports, so the build phases can be measured per job.
CARGO_TIMINGS: "true"
before_script:
- unset DD_STS_OIDC_TOKEN DD_API_KEY
# Record the runner's CPU and memory, which the build times depend on.
- sysctl hw.ncpu hw.physicalcpu hw.memsize machdep.cpu.brand_string || true
# Defensive: clean up any leftover Agent/ADP processes from prior runs on this shared
# runner. All test-Agent ports are shifted out of the canonical range (see `DEFAULT_ENV` in
# bin/correctness/panoramic/src/participants/datadog_agent.rs), so we don't need to touch a system
Expand All @@ -253,8 +258,17 @@ test-integration-linux-amd64:
- sudo pkill -9 -f /target/optimized-release/agent-data-plane || true
- sudo pkill -9 -f /target/release/datadog-intake || true
- sudo rm -rf /tmp/panoramic
# These are the prerequisites of `make test-integration-macos-ci`, one per line so that the log timestamps show the
# duration of each.
# Provisioning is network-bound, so it runs in the background while the CPU-bound builds run.
script:
- make test-integration-macos-ci
- mkdir -p "$PANORAMIC_LOG_DIR"
- make provision-macos-test-env > "$PANORAMIC_LOG_DIR/provision.log" 2>&1 &
- PROVISION_PID=$!
- make build-integration-harness-host
- make build-adp-host
- if wait "$PROVISION_PID"; then cat "$PANORAMIC_LOG_DIR/provision.log"; else cat "$PANORAMIC_LOG_DIR/provision.log"; exit 1; fi
- make test-integration-macos-run
after_script:
# Write the JUnit report first. It needs no network, and a stale mount can stall the diagnostics below.
- bash ci/tooling/report-panoramic-results.sh convert integration
Expand Down
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ MACOS_TEST_AGENT_DMG_DIR ?= /tmp/saluki-dda-dmg-cache
MACOS_TEST_AGENT_INSTALL_DIR ?= /tmp/saluki-dda/datadog-agent

# General build settings used for tooling, etc.
# Set CARGO_TIMINGS=true to make the host builds that use this write cargo timing reports under target/cargo-timings/.
CARGO_TIMINGS_ARG = $(if $(filter true,$(CARGO_TIMINGS)),--timings)
export GO_BUILD_IMAGE ?= golang:1.23-bullseye
export GO_APP_IMAGE ?= ubuntu:24.04
# TODO: move this to test/output when everyone has it in their gitignore
Expand Down Expand Up @@ -321,7 +323,7 @@ ifeq ($(shell command -v cargo-binstall >/dev/null || echo not-found), not-found
tmpdir=$$(mktemp -d); \
trap 'rm -rf "$$tmpdir"' EXIT; \
echo "[*] Downloading $$url..."; \
curl -fsSL "$$url" -o "$$tmpdir/$$asset"; \
curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 15 "$$url" -o "$$tmpdir/$$asset"; \
case "$$ext" in \
zip) unzip -q "$$tmpdir/$$asset" -d "$$tmpdir" ;; \
tgz) tar -xzf "$$tmpdir/$$asset" -C "$$tmpdir" ;; \
Expand Down Expand Up @@ -663,7 +665,7 @@ test-correctness-case: ## Runs a single correctness test case by name (usage: ma
build-panoramic: check-rust-build-tools
build-panoramic: ## Builds the panoramic binary (ADP integration test runner)
@echo "[*] Building panoramic..."
@cargo build --profile release --package panoramic
@cargo build --profile release --package panoramic $(CARGO_TIMINGS_ARG)

# The courier runs inside images panoramic does not control, so it links statically against musl. rust-lld ships with
# the toolchain and needs no musl C toolchain on the host.
Expand Down Expand Up @@ -704,13 +706,16 @@ build-adp-host: ## Builds the agent-data-plane binary for the current host (Carg
@echo "[*] Building agent-data-plane ($(BUILD_PROFILE), host target)..."
@APP_GIT_HASH="$(ADP_APP_GIT_HASH)" \
APP_BUILD_TIME="$(APP_BUILD_TIME)" \
cargo $(ADP_CARGO_BUILD_SUBCMD) --profile $(BUILD_PROFILE) --bin agent-data-plane
cargo $(ADP_CARGO_BUILD_SUBCMD) --profile $(BUILD_PROFILE) --bin agent-data-plane $(CARGO_TIMINGS_ARG)

.PHONY: build-correctness-tools-host
build-correctness-tools-host: check-rust-build-tools
build-correctness-tools-host: ## Builds datadog-intake and millstone for the current host, where the macOS integration cases run them
@echo "[*] Building datadog-intake and millstone (release, host target)..."
@cargo build --profile release --bin datadog-intake --bin millstone
.PHONY: build-integration-harness-host
build-integration-harness-host: check-rust-build-tools
build-integration-harness-host: $(if $(filter true,$(CI)),cargo-install-cargo-auditable)
build-integration-harness-host: ## Builds panoramic, datadog-intake and millstone for the current host, where the macOS integration cases run them
@echo "[*] Building panoramic, datadog-intake and millstone (release, host target)..."
# One invocation with --bin resolves features across the workspace, as build-adp-host does. With the same cargo
# subcommand as build-adp-host, the ADP build then reuses the crates that this build compiles.
@cargo $(ADP_CARGO_BUILD_SUBCMD) --profile release --bin panoramic --bin datadog-intake --bin millstone $(CARGO_TIMINGS_ARG)

.PHONY: build-adp-aix
build-adp-aix: BUILD_PROFILE ?= aix-optimized-release
Expand Down Expand Up @@ -787,7 +792,9 @@ provision-macos-test-env: ## Installs the macOS Datadog Agent named in .datadog-
@echo "[*] Agent binary: $(MACOS_TEST_AGENT_INSTALL_DIR)/bin/agent/agent"

.PHONY: test-integration-macos-ci
test-integration-macos-ci: build-panoramic build-adp-host build-correctness-tools-host provision-macos-test-env test-integration-macos-run ## CI entry point: builds binaries, ensures Agent + cert are provisioned, then runs the macOS integration cases (host processes)
# CI runs these prerequisites one per script line in .gitlab/e2e.yml, so that the log timestamps show the duration of
# each, and it provisions in the background while the builds run. Keep the two lists the same.
test-integration-macos-ci: build-integration-harness-host build-adp-host provision-macos-test-env test-integration-macos-run ## CI entry point: builds binaries, ensures Agent + cert are provisioned, then runs the macOS integration cases (host processes)

# Installs the Rust toolchain $(1) with the components $(2), unless rustup already has all of them. `rustup toolchain
# install` downloads the channel manifest even when nothing is missing, so this check lets a machine or an image that
Expand Down
2 changes: 1 addition & 1 deletion docs/development/panoramic.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ them. Each participant type picks them for the realization:
| Realization | The tools are |
| --- | --- |
| Linux container, pod | `/usr/local/bin/datadog-intake` and `/usr/local/bin/millstone` in `saluki-images/correctness-tools:latest`, which `make build-correctness-tools-image` builds. |
| macOS host process | `target/release/datadog-intake` and `target/release/millstone`, which `make build-correctness-tools-host` builds. Each runs as its own participant. `--set` replaces each path. |
| macOS host process | `target/release/datadog-intake` and `target/release/millstone`, which `make build-integration-harness-host` builds. Each runs as its own participant. `--set` replaces each path. |
| Windows container | `C:\tools\datadog-intake.exe` and `C:\tools\millstone.exe` in `saluki-images/correctness-tools:testing-windows`, which `ci/tooling/windows-integration-tests.ps1` builds. One image holds both, and each participant runs in its own container. |

## Steps
Expand Down
133 changes: 133 additions & 0 deletions docs/development/plans/macos-integration-ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# macOS integration CI speed-up plan

This file tracks the effort to make the macOS integration jobs, `test-integration-macos-arm64` and
`test-integration-macos-amd64` (`.gitlab/e2e.yml`), finish in under 6–7 minutes, consistently. Today they take 15–22
minutes and are the long pole of the pipeline.

Related work: [#3473](https://github.com/DataDog/saluki/pull/3473) runs a subset of the macOS cases on development and
merge queue pushes. It shortens the test phase on its own, and it combines with the host slots below.

The last pull request of the effort deletes this file and moves anything of lasting value into
`docs/development/panoramic.md` and `docs/development/testing.md`.

## Baseline

Measured on 2026-12-01 over the 40 most recent traces per arch. The duration percentiles also agree with the GitLab API
data for more than 2,600 arm64 runs and 1,900 amd64 runs since 2026-11-10. Reference jobs: arm64 2312980475 and
2314583606, amd64 2312980477.

| Phase | arm64 p50 / p90 | amd64 p50 / p90 |
|---|---|---|
| Queue | 0s / 1s | 27–54 min / 98–119 min |
| Tart VM prepare + sources | 36s / 46s | – |
| Toolchain, cargo-binstall, cargo-auditable (built from source in CI) | 25s / 48s | ~0 / 21s |
| Builds (panoramic, then ADP, then intake + millstone) | 8m13s / 13m26s | 11m12s / 11m53s |
| Provision the Agent DMG | 15s / 18s | 0s / 35s |
| Panoramic run (strictly serial) | 7m17s / 7m43s | 8m34s / 8m49s |
| Total | 17.1 min / 22.3 min | 19.9 min / 21.2 min |

## Root causes

1. **The tests run one at a time.**
- Panoramic gives host-process cases a single permit (`host: Semaphore::new(1)` in
`bin/correctness/panoramic/src/runner.rs`).
- The permit exists because every macOS case shares the state root `/tmp/panoramic` (`core/backend.rs`) and a fixed
set of ports. Some ports come from endpoints in `participants/agent_adp.rs` and `participants/datadog_intake.rs`.
Six are literals in `participants/datadog_agent.rs` `DEFAULT_ENV`.
- The 40 macOS cases add up to 464s on arm64 and 511s on amd64. About 70% of that time is idle 10s stability
windows, so the cases can run in parallel well.
2. **The builds are cold and sequential, and their link tails are long.**
- About half of each cargo step comes after its last `Compiling` line, mostly thin LTO and linking.
- `build-panoramic` uses `--package panoramic`, so it resolves different features from the workspace-wide `--bin`
builds. With cargo-auditable's workspace wrapper, the ADP step therefore compiles about 79 crates a second time.
- `APP_GIT_HASH` and `APP_BUILD_TIME` rerun `lib/saluki-metadata/build.rs` on every commit. That invalidates 7
heavy crates.
3. **arm64 run times have two peaks because the VMs share hosts.**
- Two Tart VMs share one mac2.metal host, and each VM runs 4 cargo jobs.
- When the other VM compiles saluki, our build time goes from a p50 of 7.8 min to 12.9 min.
- The other VM is often `unit-tests-macos-arm64`. It compiles cargo-nextest from source for about 3.5 min, because
CI sets `CARGO_BINSTALL_STRATEGIES=compile`.
4. **amd64 doesn't reuse its builds.** The 5 bare-metal hosts are persistent, but git clean deletes `target/` at the
start of every job.
5. **Retries are expensive.** `retry: 2` retries every failure. In one week that included:
- 51 amd64 `dogstatsd-replay-unix` failures;
- 14 arm64 failures downloading cargo-binstall from GitHub;
- configuration errors that fail every time, retried twice.

## Decisions

- **Build topology:** build the harness (panoramic, datadog-intake, millstone) in a parallel job, and cache it by a hash
of its inputs. ADP builds in the test job.
- **ADP profile:** always test the shipped ADP profile. ADP keeps `--profile $BUILD_PROFILE` and cargo-auditable.
- **Compile cache:** use `buildcache` with the S3 bucket that the Linux Docker builds use.
- **Intel unit tests:** `unit-tests-macos-amd64` stays pre-merge. Queueing on the Intel pool at the pipeline level is
out of scope.
- **Stability windows:** shorten them in cases that aren't about lasting behavior.
- **Tag pipelines:** they build optimized-release (fat LTO), so they don't have to meet the 6–7 minute target.
- **Parallel tests:** use a slot pool inside the panoramic runner, not several panoramic processes.

## Pull requests

The effort lands as four stacked pull requests. Each one ticks its box and adds its measured result to
[Results](#results) in the same commit.

- [x] **1. Measurement and cheap fixes.**
- Split the macOS job script into one `make` call per step, so the log timestamps show the duration of each step.
The Tart runner doesn't emit `FF_SCRIPT_SECTIONS` sections, so the job doesn't turn them on. Build with
`cargo --timings` and keep the reports as artifacts. Log the runner's CPU count and memory.
- Ignore `integration-logs/`, so the harness build doesn't count the job's log directory as a dirty checkout.
- Retry the cargo-binstall download.
- Build the harness (panoramic, datadog-intake, millstone) in one invocation with `--bin`, using the same cargo
subcommand as the ADP build (`make build-integration-harness-host`).
- Provision the Agent in the background while the builds run.
- Expected saving: 1–1.5 min.
- [ ] **2. Parallel host slots in panoramic.**
- The harness owns every port: the six literal `DEFAULT_ENV` ports become endpoints, and macOS gets endpoints for the
Agent's relocated OTLP receiver (4319/4320).
- Each host case is planned for a host slot. Slot k gets `/tmp/panoramic-k` and +10·k on every host port. Slot 0
keeps today's behavior.
- The runner runs host cases in slots (`run --host-slots`). Before the first case, a check fails if two slots would
hold the same address.
- The macOS Agent gets its own `log_file` and `confd_path`, and reclaim stops host processes in parallel.
- CI runs 4 slots on arm64.
- Expected saving: about 5 min per job.
- [ ] **3. Shorter cases.**
- Shorten stability windows from 10s to 5s where the case isn't about lasting behavior.
- Fix the `dogstatsd-replay-unix` stats race.
- Check the `adp-config-otlp` keys against one configuration snapshot.
- ADP retries its first IPC connect with exponential backoff.
- [ ] **4. Build caches.**
- Panoramic reads its revision at run time, so a cached binary reports the right revision.
- A job builds or fetches the harness, keyed by a hash of its inputs and stored in the GitLab generic package
registry. The test job builds only ADP and fetches the harness.
- Build metadata moves into the binary crate, so the shared crates stop rebuilding on every commit.
- buildcache on the Tart VMs.
- A persistent target directory on amd64.
- Retry only infrastructure failures.

## Follow-ups

- Turn on host slots on amd64, after a check of `dogstatsd-replay-unix` there.
- Lower the job timeouts once the new p99 is known.
- Ask CI-platform to:
- bake the toolchain, cargo-binstall, cargo-auditable, cargo-nextest and `buildcache` into the Tart image;
- confirm that the Tart IAM role can read and write the build cache bucket;
- place saluki's compile jobs one VM per host, or use larger VMs.

## Expected outcome

| After | arm64 p50 | amd64 p50 (main and tags) |
|---|---|---|
| Baseline | 17 min | 20 min |
| PR 1 | ~15.5 min | ~19 min |
| PR 2 | ~10.5 min | ~13.5 min |
| PR 3 | ~10 min | ~12.5 min |
| PR 4 | ~6–6.5 min (p90 ~8) | ~6–7.5 min |
| Follow-ups | ~5.5–6 min (p90 ~7) | ~6–7 min |

## Results

| Pull request | arm64 p50 / p90 | amd64 p50 / p90 | Notes |
|---|---|---|---|
| Baseline | 17.1 / 22.3 min | 19.9 / 21.2 min | Jobs 2312980475, 2314583606, 2312980477 |
| 1 | 16.6, 17.6 min (2 runs) | Not run (main only) | Jobs 2320769188 (harness 4m45s, ADP 2m45s, run 7m40s) and 2316713016 (a slow VM). Each build ends with about 2 min on one core |
Loading