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

[7.1.0] Make Bazel's RAM estimate container aware #20644

Merged
merged 1 commit into from
Jan 11, 2024

Commits on Dec 21, 2023

  1. Make Bazel's RAM estimate container aware

    As of JDK 14, `OperatingSystemMXBean` provides information about system memory that is container-aware. Outside containers, it uses the same mechanisms as Bazel to determine available RAM (`/proc/meminfo` on Linux, `hw.memsize` on macOS) and can thus be used as a drop-in replacement for the custom implementation.
    
    A small caveat is that Bazel's macOS RAM estimate was based on converting bytes to "MB" via a divisor of `1000^2` instead of `1024^2`, resulting in a consistent overestimate compared to an identical Linux machine that is now corrected.
    
    This opportunity was missed in bazelbuild#16512 since `OperatingSystemMXBean` is based on a complete Java implementation of cgroups handling and doesn't go through the `os::total_memory` or `os::physical_memory` Hotspot functions.
    
    RELNOTES[INC]:
    * On Linux, Bazel's RAM estimate for the host machine is now aware of container resource limits.
    * On macOS, Bazel no longer consistently overestimates the total RAM by ~5% (`1024^2/1000^2`).
    * On Windows, Bazel's RAM estimate is now generally more accurate as it is no longer influenced by JVM heuristics.
    
    Fixes bazelbuild#3886
    
    Closes bazelbuild#20435.
    
    PiperOrigin-RevId: 588718034
    Change-Id: I2daafa0567740a1b149ca8756ec27f102129283c
    fmeum authored and bazel-io committed Dec 21, 2023
    Configuration menu
    Copy the full SHA
    eac4b6b View commit details
    Browse the repository at this point in the history