Have rules_rust specify the amount of memory required for actions

Open
#4,428 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
63/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
build-system

Research direction

Read rust/private/rustc_resource_set.bzl and the ctx.actions.run call in rust/private/clippy.bzl around lines 235–246; compare them with rust/private/rustc.bzl around line 2060 and the linked PR #3474. Start by checking how resource estimates are currently supplied for Rust compiler actions. Done means relevant actions specify memory estimates so Bazel can account for their memory use; the issue does not give target values or named tests.

Written by the indexing model from the issue text.

Description

awaiting-response core

Is your feature request related to a problem? Please describe.
rust/private/rustc.bzl:2060 passes resource_set = get_rustc_resource_set(toolchain). Every function in rust/private/rustc_resource_set.bzl returns only a CPU count, e.g. return {"cpu": 1}. rust/private/clippy.bzl:235-246, the ctx.actions.run(mnemonic = "Clippy", ...) call, has no resource_set, so Clippy actions get a default of 250 MB.

This means bazel doesn't properly limit resources based on system memory available because it thinks actions use the default of 250 MB. This can cause an overutilization of resources and crash the actions.

Describe the solution you'd like
Specify resource utilization estimates in actions.

Describe alternatives you've considered
Cap system CPU or job parallelization. This artificially restricts other action specifications that prescribe the resource requirements appropriately.

Additional context
It looks like https://github.com/bazelbuild/rules_rust/pull/3474 started this but nothing picked it up.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.