Skip to content

pkg_rpm: reserve local resources for threaded payload compression - #1094

Open
chouquette wants to merge 1 commit into
bazelbuild:mainfrom
chouquette:chouquette/rpm-payload-resources
Open

chouquette wants to merge 1 commit into
bazelbuild:mainfrom
chouquette:chouquette/rpm-payload-resources

Conversation

@chouquette

Copy link
Copy Markdown
Contributor

binary_payload_compression accepts rpm's threaded payload modes such as w9T8.xzdio, but MakeRpm always runs with Bazel's default reservation of one CPU, which the attribute documentation warns about.

This derives a resource_set for MakeRpm from the compression value when it requests an explicit thread count:

  • the action reserves the requested CPUs, rounded up to 2, 4, 8 or 16 and capped at 16;
  • for xz, it also reserves the memory multi-threaded xz needs per thread, using the worst preset of the level group (up to -6, or -7 to -9).

Values without an explicit thread count keep the current behavior.

resource_set callbacks have to be top-level functions and cannot be parameterized, which is why the supported thread counts are enumerated.

Tested by building two w6T8.xzdio rpms with --local_resources=cpu=8: the second MakeRpm waits for the first one, while two single-threaded rpms still run in parallel.

@chouquette
chouquette marked this pull request as ready for review November 4, 2026 10:35
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Nov 5, 2026
### What does this PR do?

Sets the rpm payload compression in `dd_pkg_rpm` to xz: level 9 when `//:is_release` is set and level 5 otherwise. Packages can no longer override it.
Also enable multi threaded compression.

### Motivation

The omnibus rpms are xz-compressed (they require `rpmlib(PayloadIsXz)`), unlike the Bazel ones. The package parity check (#58991) reports the difference.
The levels mirror omnibus, using the release flag as the replacement for its deploy detection.

This PR is stacked on the release opt-in PR (#59217), so that regular builds default to level 5.

### Describe how you validated your changes

Built a small rpm through `dd_pkg_rpm`: xz level 5 by default and level 9 with `--config=release`. Both require `rpmlib(PayloadIsXz)`.

### Additional notes

bazelbuild/rules_pkg#1094 is related so that we can avoid overcommiting on resources.
In our case, since packaging are usually the last actions, we shouldn't notice much difference though.

Co-authored-by: hugo.beauzee <hugo.beauzee@datadoghq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant