mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-07 07:02:53 +03:00
don't fail the build if /proc/meminfo is missing or unexpected
Summary: Occasionally we see reports [1] that /proc/meminfo is missing or has unexpected values on Linux. Instead of failing the build, guess a reasonable value, at the risk that this will unnecessarily limit the build's concurrency. [1] https://github.com/facebook/watchman/issues/1040 Reviewed By: genevievehelsel Differential Revision: D38126612 fbshipit-source-id: 9d9d9f6003703acf6dffcdd5b2022f0f7b3aa691
This commit is contained in:
committed by
Facebook GitHub Bot
parent
19e6422d18
commit
82d1cc37e0
@@ -56,7 +56,10 @@ def get_linux_type() -> Tuple[Optional[str], Optional[str], Optional[str]]:
|
||||
def _get_available_ram_linux() -> int:
|
||||
# TODO: Ideally, this function would inspect the current cgroup for any
|
||||
# limits, rather than solely relying on system RAM.
|
||||
with open("/proc/meminfo") as f:
|
||||
|
||||
meminfo_path = "/proc/meminfo"
|
||||
try:
|
||||
with open(meminfo_path) as f:
|
||||
for line in f:
|
||||
try:
|
||||
key, value = line.split(":", 1)
|
||||
@@ -69,8 +72,16 @@ def _get_available_ram_linux() -> int:
|
||||
return int(value) // 1024
|
||||
except ValueError:
|
||||
continue
|
||||
except OSError:
|
||||
print("error opening {}".format(meminfo_path), end="", file=sys.stderr)
|
||||
else:
|
||||
print(
|
||||
"{} had no valid MemAvailable".format(meminfo_path), end="", file=sys.stderr
|
||||
)
|
||||
|
||||
raise NotImplementedError("/proc/meminfo had no valid MemAvailable")
|
||||
guess = 8
|
||||
print(", guessing {} GiB".format(guess), file=sys.stderr)
|
||||
return guess * 1024
|
||||
|
||||
|
||||
def _get_available_ram_macos() -> int:
|
||||
|
Reference in New Issue
Block a user