Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent resource management across actions and resource types #19679

Open
3 of 5 tasks
AlessandroPatti opened this issue Sep 29, 2023 · 2 comments
Open
3 of 5 tasks
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Local-Exec Issues and PRs for the Execution (Local) team type: feature request

Comments

@AlessandroPatti
Copy link
Contributor

AlessandroPatti commented Sep 29, 2023

Description of the feature request:

There are several way of defining and allocating resources for bazel:

  • --local_cpu_resources and --local_ram_resources can be used to define the amount of cpu and ram available for bazel to consume. They both accept decimal values (float)
  • --local_extra_resources can be used to model arbitrary abstract resources, also as floats
  • The cpu:<n> tag (or execution info) can be used to request more cpus for an action (defaults to 1)
    • Only works for tests
    • Only allows integer values, but it is modelled internally as a double
  • The resources:<resource>:<amount> can be used to request any amount of an arbitrary resource
    • Only applied to tests
    • Accepts float values
  • As far as I understand, there is no way of requesting more memory (ram), even thou it is modelled internally as number of MB (as a double value)

I would like have fine-grained controll on all the resources types and all the actions, with an unified api, which stores all the values as doubles, something like:

  • resources:<resource>:<amount> allows allocating any resource, including cpu and memory
  • --local_resources=<resource>=<amount> can be used to specify the amount of any resource available for bazel to use. This would include cpu and memory
  • --default_test_resources=<resource>=<small>,<medium>,<large>,<enormous> allows setting the default allocation for test based on the test size.
  • --default_resources=<resource>=<amount> can be used to change the default allocation for all actions
  • resources:<resource>:<amount> can be applied to any action (not test only)

Which category does this issue belong to?

Local Execution

What underlying problem are you trying to solve with this feature?

In large, multi language repositories, the default values for resource allocation might not be suitable for all targets/actions. When that happens, bazel ends up over (or under) scheduling tasks, which affects performance and stability. With fine grained controll over the resource allocation, the build can be tweaked according to its needs.

Which operating system are you running Bazel on?

N/A

What is the output of bazel info release?

release 6.3.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@sgowroji sgowroji added the team-Local-Exec Issues and PRs for the Execution (Local) team label Sep 29, 2023
@tjgq tjgq added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Oct 10, 2023
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
Remove special handling of cpu and memory, and instead track them as any other resource. This has a few advantages:
  - Significant code clean up, keep only the logic for generic resource around
  - Consistent resources type (double) for all resource

Relates to #19679

Closes #19839.

PiperOrigin-RevId: 585926931
Change-Id: Id0d6a14e9c151c3895f55d1808b6bd66eecf98b3
@jin
Copy link
Member

jin commented Nov 29, 2023

Related: #10443

iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Nov 30, 2023
Remove special handling of cpu and memory, and instead track them as any other resource. This has a few advantages:
  - Significant code clean up, keep only the logic for generic resource around
  - Consistent resources type (double) for all resource

Relates to bazelbuild#19679

Closes bazelbuild#19839.

PiperOrigin-RevId: 585926931
Change-Id: Id0d6a14e9c151c3895f55d1808b6bd66eecf98b3
iancha1992 added a commit that referenced this issue Nov 30, 2023
Remove special handling of cpu and memory, and instead track them as any
other resource. This has a few advantages:
- Significant code clean up, keep only the logic for generic resource
around
  - Consistent resources type (double) for all resource

Relates to #19679

Closes #19839.

Commit
ebe4d0d

PiperOrigin-RevId: 585926931
Change-Id: Id0d6a14e9c151c3895f55d1808b6bd66eecf98b3

Co-authored-by: Alessandro Patti <[email protected]>
@DavidANeil
Copy link
Contributor

This is not strictly related to this task, but just musing:

I wonder if assigned resources ought to be available to an action/test as an environment variable.
That way, guard rails can be imposed in user-land that if a resource is not assigned to the target, then it should not be used while executing.

As an example, I am imagining us using something like --local_resources=clipboard=1 and then resources:clipboard:1 on tests that access the clipboard.
Then we could add a hook in where we are accessing the system clipboard and fail fast if the test has not been assigned that resource.

copybara-service bot pushed a commit that referenced this issue Feb 12, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting the default resource utilization for tests. The flag follow a syntax simialar to `--local_resources=<resource>=<value>`, in that it allow assigning different resource types, and `--test_timeout=<value(s)>`, which accepts either 1 or 4 intergers to assign to all test sizes or to each individually.

Relates to #19679

Closes #20839.

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9
bazel-io pushed a commit to bazel-io/bazel that referenced this issue Feb 12, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting the default resource utilization for tests. The flag follow a syntax simialar to `--local_resources=<resource>=<value>`, in that it allow assigning different resource types, and `--test_timeout=<value(s)>`, which accepts either 1 or 4 intergers to assign to all test sizes or to each individually.

Relates to bazelbuild#19679

Closes bazelbuild#20839.

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9
iancha1992 pushed a commit to bazel-io/bazel that referenced this issue Feb 14, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting the default resource utilization for tests. The flag follow a syntax simialar to `--local_resources=<resource>=<value>`, in that it allow assigning different resource types, and `--test_timeout=<value(s)>`, which accepts either 1 or 4 intergers to assign to all test sizes or to each individually.

Relates to bazelbuild#19679

Closes bazelbuild#20839.

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9
github-merge-queue bot pushed a commit that referenced this issue Feb 15, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting
the default resource utilization for tests. The flag follow a syntax
simialar to `--local_resources=<resource>=<value>`, in that it allow
assigning different resource types, and `--test_timeout=<value(s)>`,
which accepts either 1 or 4 intergers to assign to all test sizes or to
each individually.

Relates to #19679

Closes #20839.

Commit
0c5b6e8

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9

Co-authored-by: Alessandro Patti <[email protected]>
AlessandroPatti added a commit to AlessandroPatti/bazel that referenced this issue Feb 19, 2024
Remove special handling of cpu and memory, and instead track them as any other resource. This has a few advantages:
  - Significant code clean up, keep only the logic for generic resource around
  - Consistent resources type (double) for all resource

Relates to bazelbuild#19679

Closes bazelbuild#19839.

PiperOrigin-RevId: 585926931
Change-Id: Id0d6a14e9c151c3895f55d1808b6bd66eecf98b3
AlessandroPatti added a commit to AlessandroPatti/bazel that referenced this issue Feb 19, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting the default resource utilization for tests. The flag follow a syntax simialar to `--local_resources=<resource>=<value>`, in that it allow assigning different resource types, and `--test_timeout=<value(s)>`, which accepts either 1 or 4 intergers to assign to all test sizes or to each individually.

Relates to bazelbuild#19679

Closes bazelbuild#20839.

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9
apattidb pushed a commit to databricks/bazel that referenced this issue Feb 20, 2024
Remove special handling of cpu and memory, and instead track them as any other resource. This has a few advantages:
  - Significant code clean up, keep only the logic for generic resource around
  - Consistent resources type (double) for all resource

Relates to bazelbuild#19679

Closes bazelbuild#19839.

PiperOrigin-RevId: 585926931
Change-Id: Id0d6a14e9c151c3895f55d1808b6bd66eecf98b3
apattidb pushed a commit to databricks/bazel that referenced this issue Feb 20, 2024
Add `--default_test_resources=<resource>=<value(s)>` that allows setting the default resource utilization for tests. The flag follow a syntax simialar to `--local_resources=<resource>=<value>`, in that it allow assigning different resource types, and `--test_timeout=<value(s)>`, which accepts either 1 or 4 intergers to assign to all test sizes or to each individually.

Relates to bazelbuild#19679

Closes bazelbuild#20839.

PiperOrigin-RevId: 606233269
Change-Id: Ia53e42820ba9aa646b0600fe4e9f95f146d7b2b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Local-Exec Issues and PRs for the Execution (Local) team type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants