bazelbuild / bazelbuild/rules_cc

resource_set for linking actions is too conservative

Open
#628 2 comments 3 reactions 0 assignees View on GitHub
P3
Dominant language
Starlark
Stars
247
Forks
196
PR merge metrics
No merged PRs in 30d

Description

I came across [usage](https://github.com/bazelbuild/rules_cc/blob/9473f5d78133f684b553e2b88c6ed31069bd7a4d/cc/private/link/finalize_link_action.bzl) of `resource_set` for linking actions and the formula that is used to compute how much RAM we should allocate per linking action seems to be too conservative:
```starlark
return {"memory": max(50, -100 + 0.1 * inputs), "cpu": 1}
```

So, if one has 1000 inputs that leaves one with 50 Mb of RAM allocated for a single linking action which makes bazel very eager to schedule as many linking actions as it can simultaneously that sometimes leads to crashes due to OOM Killer, especially in containerized environments. I think, this formula should either be set to higher values or, ideally, we should expose resource allocation for both compilation and linking actions (e.g. `size` attribute for each `cc_*` rule)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.