Bug 1251076 - Record ccache stats in build telemetry data r?gps
Using ccache can have a big impact on compile times but we don't currently
capture ccache statistics.
MozReview-Commit-ID: CdrScyAh64I
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -454,16 +454,17 @@ class Build(MachCommandBase):
monitor.finish(record_usage=status==0)
high_finder, finder_percent = monitor.have_high_finder_usage()
if high_finder:
print(FINDER_SLOW_MESSAGE % finder_percent)
ccache_end = monitor.ccache_stats()
+ ccache_diff = None
if ccache_start and ccache_end:
ccache_diff = ccache_end - ccache_start
if ccache_diff:
self.log(logging.INFO, 'ccache',
{'msg': ccache_diff.hit_rate_message()}, "{msg}")
notify_minimum_time = 300
try:
@@ -496,25 +497,35 @@ class Build(MachCommandBase):
telemetry_handler = getattr(self._mach_context,
'telemetry_handler', None)
telemetry_data = monitor.record_resource_usage()
# Record build configuration data. For now, we cherry pick
# items we need rather than grabbing everything, in order
# to avoid accidentally disclosing PII.
+ telemetry_data['substs'] = {}
try:
- moz_artifact_builds = self.substs.get('MOZ_ARTIFACT_BUILDS',
- False)
- telemetry_data['substs'] = {
- 'MOZ_ARTIFACT_BUILDS': moz_artifact_builds,
- }
+ for key in ['MOZ_ARTIFACT_BUILDS', 'MOZ_USING_CCACHE']:
+ value = self.substs.get(key, False)
+ telemetry_data['substs'][key] = value
except BuildEnvironmentNotFoundException:
pass
+ # Grab ccache stats if available. We need to be careful not
+ # to capture information that can potentially identify the
+ # user (such as the cache location)
+ if ccache_diff:
+ telemetry_data['ccache'] = {}
+ for key in [key[0] for key in ccache_diff.STATS_KEYS]:
+ try:
+ telemetry_data['ccache'][key] = ccache_diff._values[key]
+ except KeyError:
+ pass
+
telemetry_handler(self._mach_context, telemetry_data)
# Only for full builds because incremental builders likely don't
# need to be burdened with this.
if not what:
try:
# Fennec doesn't have useful output from just building. We should
# arguably make the build action useful for Fennec. Another day...