Skip to content

Ability to override RAM estimate for cppcompile action #25770

Open

Description

@travisdowns

Description of the feature request:

Currently our bazel build crashes on most machines due to an inaccurate RAM estimation: our .cpp compiles take 2-4 GB of RAM so will crash on machines where the available RAM/CPU count is less than that.

Currently there doesn't seem to be a way to override the estimate:

return ResourceSet.createWithRamCpu(/* memoryMb= */ 80 + 0.7 * inputs, /* cpu= */ 1);

for this action, though resource_set is available to do this for some other actions. It is also not clear what "inputs" is in the context of cppcompile actions (this probably makes more sense for links).

Which category does this issue belong to?

No response

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

No crashing on parallel builds where each compile job uses a lot of RAM.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 7.5.0

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

n/a

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

For which repo?

Have you found anything relevant by searching the web?

Yes. It seems like this functionality is not available currently for native jobs, though things like resources:memory tag can work for some other jobs.

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

Not at this time.

Activity

  1. added
    untriaged
    on Apr 4, 2025
  2. added
    team-Rules-CPP
    on Apr 4, 2025
  3. rockwotj commented on Apr 4, 2025

    @rockwotj
    Contributor

    return ResourceSet.createWithRamCpu(/* memoryMb= */ 80 + 0.7 * inputs, /* cpu= */ 1);

    Note this isn't used unless you specify an undocumented flag, by default it's 250MiB and 1 CPU.

  4. keith commented on Apr 4, 2025

    @keith
    Member

    does using tags = ["resources:memory:N"] work for you?

  5. rockwotj commented on Apr 4, 2025

    @rockwotj
    Contributor

    @keith I believe that only works for tests, at least in the compile action I don't see code for that tag handling

  6. benjaminp commented on Apr 4, 2025

    @benjaminp
    Collaborator

    related saga: #17368

  7. travisdowns commented on Apr 7, 2025

    @travisdowns
    Author

    related saga: #17368

    Indeed it's related, but I though it's worth having another one for cppcompile as:

    • As far as I can tell (thanks mostly to @rockwotj), cppcompile doesn't use the linker-style estimate by default, while the linker does.
    • Estimating compile memory use based on input files seems even less justified than the linker case.
  8. travisdowns commented on Apr 7, 2025

    @travisdowns
    Author

    does using tags = ["resources:memory:N"] work for you?

    No, I tried adding resources:memory:10000m to the cc_library invocations but there was no different in behavior (32 compile jobs were started on my 32-CPU host with 96 GB of RAM, while if it was working I'd expect at most 9).

  9. added
    team-Performance
    P3
    and removed
    untriaged
    on Aug 6, 2025
  10. keith commented on Apr 13, 2026

    @keith
    Member

    #29284 would let you override this on a per-platform / per target basis, but still only statically. I also submitted #29283 which would allow you to target those resource constraints more granularly

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3team-Performanceteam-Rules-CPPtype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions