зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1515901 - Avoid loading mozconfig multiple times from MozbuildObject. r=froydnj
When running `mach help`, mozconfig is loaded multiple times, and even with an almost empty mozconfig, this makes mach help take close to 10 seconds on my Windows machine. With some memoization, the time to run mach help gets down to 2s. Differential Revision: https://phabricator.services.mozilla.com/D15186 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8123087c92
Коммит
012ea52a90
|
@ -32,7 +32,10 @@ from .mozconfig import (
|
|||
MozconfigLoader,
|
||||
)
|
||||
from .pythonutil import find_python3_executable
|
||||
from .util import memoized_property
|
||||
from .util import (
|
||||
memoize,
|
||||
memoized_property,
|
||||
)
|
||||
from .virtualenv import VirtualenvManager
|
||||
|
||||
|
||||
|
@ -211,6 +214,16 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
|
||||
return self._virtualenv_manager
|
||||
|
||||
@staticmethod
|
||||
@memoize
|
||||
def get_mozconfig(topsrcdir, path, env_mozconfig):
|
||||
# env_mozconfig is only useful for unittests, which change the value of
|
||||
# the environment variable, which has an impact on autodetection (when
|
||||
# path is MozconfigLoader.AUTODETECT), and memoization wouldn't account
|
||||
# for it without the explicit (unused) argument.
|
||||
loader = MozconfigLoader(topsrcdir)
|
||||
return loader.read_mozconfig(path=path)
|
||||
|
||||
@property
|
||||
def mozconfig(self):
|
||||
"""Returns information about the current mozconfig file.
|
||||
|
@ -218,8 +231,8 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
This a dict as returned by MozconfigLoader.read_mozconfig()
|
||||
"""
|
||||
if not isinstance(self._mozconfig, dict):
|
||||
loader = MozconfigLoader(self.topsrcdir)
|
||||
self._mozconfig = loader.read_mozconfig(path=self._mozconfig)
|
||||
self._mozconfig = self.get_mozconfig(
|
||||
self.topsrcdir, self._mozconfig, os.environ.get('MOZCONFIG'))
|
||||
|
||||
return self._mozconfig
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче