Bug 944842 - Record and warn about swapping during builds; r=glandium

--HG--
extra : rebase_source : 3930a423514b5422ba23129b4da2a38f863bffbe
extra : amend_source : a9368fce73d02dc1f5073e652e4ab0b33f4c0a21
This commit is contained in:
Gregory Szorc 2013-12-09 18:58:13 +09:00
parent cfac358560
commit ca20964835
2 changed files with 51 additions and 0 deletions

View File

@ -453,6 +453,28 @@ class BuildMonitor(MozbuildObject):
return finder_percent > 25, finder_percent
def have_excessive_swapping(self):
"""Determine whether there was excessive swapping during the build.
Returns a tuple of (excessive, swap_in, swap_out). All values are None
if no swap information is available.
"""
if not self.have_resource_usage:
return None, None, None
swap_in = sum(m.swap.sin for m in self.resources.measurements)
swap_out = sum(m.swap.sout for m in self.resources.measurements)
# The threshold of 1024 MB has been arbitrarily chosen.
#
# Choosing a proper value that is ideal for everyone is hard. We will
# likely iterate on the logic until people are generally satisfied.
# If a value is too low, the eventual warning produced does not carry
# much meaning. If the threshold is too high, people may not see the
# warning and the warning will thus be ineffective.
excessive = swap_in > 512 * 1048576 or swap_out > 512 * 1048576
return excessive, swap_in, swap_out
@property
def have_resource_usage(self):
"""Whether resource usage is available."""
@ -480,6 +502,14 @@ class BuildMonitor(MozbuildObject):
self._log_resource_usage('Overall system resources', 'resource_usage',
self.end_time - self.start_time, cpu_percent, cpu_times, io)
excessive, sin, sout = self.have_excessive_swapping()
if excessive is not None and (sin or sout):
sin /= 1048576
sout /= 1048576
self.log(logging.WARNING, 'swap_activity',
{'sin': sin, 'sout': sout},
'Swap in/out (MB): {sin}/{sout}')
o = dict(
version=1,
start=self.start_time,

View File

@ -49,6 +49,23 @@ Preferences.
===================
'''.strip()
EXCESSIVE_SWAP_MESSAGE = '''
===================
PERFORMANCE WARNING
Your machine experienced a lot of swap activity during the build. This is
possibly a sign that your machine doesn't have enough physical memory or
not enough available memory to perform the build. It's also possible some
other system activity during the build is to blame.
If you feel this message is not appropriate for your machine configuration,
please file a Core :: Build Config bug at
https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=Build%20Config
and tell us about your machine and build configuration so we can adjust the
warning heuristic.
===================
'''
class TerminalLoggingHandler(logging.Handler):
"""Custom logging handler that works with terminal window dressing.
@ -424,6 +441,10 @@ class Build(MachCommandBase):
print('Your build was successful!')
if monitor.have_resource_usage:
excessive, swap_in, swap_out = monitor.have_excessive_swapping()
if excessive:
print(EXCESSIVE_SWAP_MESSAGE)
print('To view resource usage of the build, run |mach '
'resource-usage|.')