From b90f6190376a00384192331c3d02e84ad40633e5 Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Tue, 11 Dec 2018 16:52:31 -0500 Subject: [PATCH] Performance improvements for CDash reporter * Record build output as an array of lines rather than concatenating to a single large string. * Use string.find to avoid running re.search on every line of output. --- lib/spack/spack/reporters/cdash.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index 638cc7a889..5ba2c0c6cc 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -78,7 +78,7 @@ def build_report(self, filename, report_data): for phase in cdash_phases: report_data[phase] = {} - report_data[phase]['log'] = "" + report_data[phase]['loglines'] = [] report_data[phase]['status'] = 0 report_data[phase]['endtime'] = self.endtime @@ -97,7 +97,9 @@ def build_report(self, filename, report_data): current_phase = '' cdash_phase = '' for line in package['stdout'].splitlines(): - match = phase_regexp.search(line) + match = None + if line.find("Executing phase: '") != -1: + match = phase_regexp.search(line) if match: current_phase = match.group(1) if current_phase not in map_phases_to_cdash: @@ -107,12 +109,12 @@ def build_report(self, filename, report_data): map_phases_to_cdash[current_phase] if cdash_phase not in phases_encountered: phases_encountered.append(cdash_phase) - report_data[cdash_phase]['log'] += \ - text_type("{0} output for {1}:\n".format( - cdash_phase, package['name'])) + report_data[cdash_phase]['loglines'].append( + text_type("{0} output for {1}:".format( + cdash_phase, package['name']))) elif cdash_phase: - report_data[cdash_phase]['log'] += \ - xml.sax.saxutils.escape(line) + "\n" + report_data[cdash_phase]['loglines'].append( + xml.sax.saxutils.escape(line)) phases_encountered.append('update') @@ -126,8 +128,9 @@ def build_report(self, filename, report_data): self.starttime = self.endtime - total_duration for phase in phases_encountered: report_data[phase]['starttime'] = self.starttime - errors, warnings = parse_log_events( - report_data[phase]['log'].splitlines()) + report_data[phase]['log'] = \ + '\n'.join(report_data[phase]['loglines']) + errors, warnings = parse_log_events(report_data[phase]['loglines']) nerrors = len(errors) if phase == 'configure' and nerrors > 0: