From 2979229696cb83eef925a34cedcf56856f69b080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Tue, 2 Jun 2020 07:46:45 +0200 Subject: _platform: Drop maximize_open_file_limit() Without the SafeHardlinks FUSE filesystem there is no longer a need to increase the open file limit. --- src/buildstream/_platform/darwin.py | 24 ------------------------ src/buildstream/_platform/platform.py | 17 ----------------- src/buildstream/_platform/win32.py | 23 ----------------------- 3 files changed, 64 deletions(-) (limited to 'src/buildstream') diff --git a/src/buildstream/_platform/darwin.py b/src/buildstream/_platform/darwin.py index fc9be342f..00bca2c4c 100644 --- a/src/buildstream/_platform/darwin.py +++ b/src/buildstream/_platform/darwin.py @@ -15,36 +15,12 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . -import resource - from ..sandbox import SandboxDummy from .platform import Platform class Darwin(Platform): - - # This value comes from OPEN_MAX in syslimits.h - OPEN_MAX = 10240 - - def maximize_open_file_limit(self): - # Note that on Mac OSX, you may not be able to simply set the soft - # limit to the reported hard limit, as it may not be the only limit in - # effect. The output of these commands may be somewhat independent: - # - # $ launchctl limit - # $ sysctl -a | grep files - # - # The OPEN_MAX value from syslimits.h seems to be fairly safe, although - # users may tweak their individual systems to have different values. - # Without a way to determine what the real limit is, we risk failing to - # increase the limit. Perhaps the complication is why psutil does not - # support rlimit on Mac. - # - old_soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) - soft_limit = min(max(self.OPEN_MAX, old_soft_limit), hard_limit) - resource.setrlimit(resource.RLIMIT_NOFILE, (soft_limit, hard_limit)) - @staticmethod def _check_dummy_sandbox_config(config): pass diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index d0debfc7b..84d1fb231 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -39,7 +39,6 @@ class Platform: # force_sandbox (bool): Force bst to use a particular sandbox # def __init__(self, force_sandbox=None): - self.maximize_open_file_limit() self._local_sandbox = None self.dummy_reasons = [] self._setup_sandbox(force_sandbox) @@ -248,22 +247,6 @@ class Platform: "Platform {platform} does not implement check_sandbox_config()".format(platform=type(self).__name__) ) - def maximize_open_file_limit(self): - # Need to set resources for _frontend/app.py as this is dependent on the platform - # SafeHardlinks FUSE needs to hold file descriptors for all processes in the sandbox. - # Avoid hitting the limit too quickly, by increasing it as far as we can. - - # Import this late, as it is not available on Windows. Note that we - # could use `psutil.Process().rlimit` instead, but this would introduce - # a dependency on the `prlimit(2)` call, which seems to only be - # available on Linux. For more info: - # https://github.com/giampaolo/psutil/blob/cbf2bafbd33ad21ef63400d94cb313c299e78a45/psutil/_psutil_linux.c#L45 - import resource - - soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) - if soft_limit != hard_limit: - resource.setrlimit(resource.RLIMIT_NOFILE, (hard_limit, hard_limit)) - def _setup_dummy_sandbox(self): raise ImplError( "Platform {platform} does not implement _setup_dummy_sandbox()".format(platform=type(self).__name__) diff --git a/src/buildstream/_platform/win32.py b/src/buildstream/_platform/win32.py index 33645e030..5045c9e3e 100644 --- a/src/buildstream/_platform/win32.py +++ b/src/buildstream/_platform/win32.py @@ -20,29 +20,6 @@ from .platform import Platform class Win32(Platform): - def maximize_open_file_limit(self): - # Note that on Windows, we don't have the 'resource' module to help us - # configure open file limits. - # - # 'psutil' provides an rlimit implementation that is only available on - # Linux, as of version 5.3. - # - # Given that this limit is only important for SafeHardLinks FUSE, and - # we don't have FUSE on Windows, this won't be an obstacle for now. - # - # If it does turn out to be an obstacle, beware that the Windows API - # `_setmaxstdio` for increasing the open file limit only applies to the - # 'stream I/O level', i.e. `fopen()` and friends. CPython opens files - # using `_wopen()`, which is at the 'low I/O level'. - # - # You can see this in the function `os_open_impl` in `posixmodule.c` in - # CPython version 3.9. - # - # For more information: - # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio - # - pass - @staticmethod def _check_dummy_sandbox_config(config): pass -- cgit v1.2.1