[LNT] r348877 - Don't call repr on all timed functions arguments
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 11 10:47:44 PST 2018
Author: cmatthews
Date: Tue Dec 11 10:47:44 2018
New Revision: 348877
URL: http://llvm.org/viewvc/llvm-project?rev=348877&view=rev
Log:
Don't call repr on all timed functions arguments
This was causing a huge amount of lazy loads from the database.
Modified:
lnt/trunk/lnt/server/db/fieldchange.py
lnt/trunk/lnt/server/db/regression.py
lnt/trunk/lnt/testing/util/commands.py
Modified: lnt/trunk/lnt/server/db/fieldchange.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/fieldchange.py?rev=348877&r1=348876&r2=348877&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/fieldchange.py (original)
+++ lnt/trunk/lnt/server/db/fieldchange.py Tue Dec 11 10:47:44 2018
@@ -120,6 +120,13 @@ def regenerate_fieldchanges_for_run(sess
.filter(ts.FieldChange.field_id.in_(field_ids))
.all())
+ active_indicators = session.query(ts.RegressionIndicator) \
+ .join(ts.Regression) \
+ .filter(or_(ts.Regression.state == RegressionState.DETECTED,
+ ts.Regression.state == RegressionState.DETECTED_FIXED)) \
+ .options(joinedload(ts.RegressionIndicator.field_change)) \
+ .all()
+
for field in list(ts.Sample.get_metric_fields()):
for test_id in runinfo.test_ids:
f = None
@@ -158,12 +165,12 @@ def regenerate_fieldchanges_for_run(sess
session.add(f)
try:
found, new_reg = identify_related_changes(session, ts,
- f)
+ f, active_indicators)
except ObjectDeletedError:
# This can happen from time to time.
# So, lets retry once.
found, new_reg = identify_related_changes(session, ts,
- f)
+ f, active_indicators)
if found:
logger.info("Found field change: {}".format(
@@ -174,6 +181,7 @@ def regenerate_fieldchanges_for_run(sess
f.old_value = result.previous
f.new_value = result.current
f.run = run
+
session.commit()
regressions = session.query(ts.Regression).all()[::-1]
@@ -206,7 +214,7 @@ def percent_similar(a, b):
@timed
-def identify_related_changes(session, ts, fc):
+def identify_related_changes(session, ts, fc, active_indicators):
"""Can we find a home for this change in some existing regression? If a
match is found add a regression indicator adding this change to that
regression, otherwise create a new regression for this change.
@@ -215,13 +223,6 @@ def identify_related_changes(session, ts
ranges. Then looks for changes that are similar.
"""
- active_indicators = session.query(ts.RegressionIndicator) \
- .join(ts.Regression) \
- .filter(or_(ts.Regression.state == RegressionState.DETECTED,
- ts.Regression.state == RegressionState.DETECTED_FIXED)) \
- .options(joinedload(ts.RegressionIndicator.field_change)) \
- .all()
-
for change in active_indicators:
regression_change = change.field_change
@@ -245,10 +246,12 @@ def identify_related_changes(session, ts
confidence))
ri = ts.RegressionIndicator(regression, fc)
session.add(ri)
+ active_indicators.append(ri)
# Update the default title if needed.
rebuild_title(session, ts, regression)
session.commit()
return True, regression
logger.info("Could not find a partner, creating new Regression for change")
- new_reg = new_regression(session, ts, [fc.id])
+ new_reg, new_indicators = new_regression(session, ts, [fc.id])
+ active_indicators.extend(new_indicators)
return False, new_reg
Modified: lnt/trunk/lnt/server/db/regression.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/regression.py?rev=348877&r1=348876&r2=348877&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/regression.py (original)
+++ lnt/trunk/lnt/server/db/regression.py Tue Dec 11 10:47:44 2018
@@ -44,13 +44,18 @@ def new_regression(session, ts, field_ch
title = MSG
regression = ts.Regression(title, "", RegressionState.DETECTED)
session.add(regression)
+ new_ris = []
for fc_id in field_changes:
- fc = get_fieldchange(session, ts, fc_id)
+ if type(fc_id) == int:
+ fc = get_fieldchange(session, ts, fc_id)
+ else:
+ fc = fc_id
ri1 = ts.RegressionIndicator(regression, fc)
- session.add(ri1)
+ new_ris.append(ri1)
+ session.add_all(new_ris)
rebuild_title(session, ts, regression)
session.commit()
- return regression
+ return regression, new_ris
def rebuild_title(session, ts, regression):
Modified: lnt/trunk/lnt/testing/util/commands.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/util/commands.py?rev=348877&r1=348876&r2=348877&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/util/commands.py (original)
+++ lnt/trunk/lnt/testing/util/commands.py Tue Dec 11 10:47:44 2018
@@ -14,11 +14,8 @@ def timed(func):
t_start = time.time()
result = func(*args, **kw)
t_end = time.time()
- short_args = repr(args)
- if len(short_args) > 80:
- short_args = short_args[0:80]
delta = t_end - t_start
- msg = '%r (%s, %r) %2.2f sec' % (func.__name__, short_args, kw, delta)
+ msg = '%r %2.2f sec' % (func.__name__, delta)
if delta > 10:
logger.warning(msg)
else:
More information about the llvm-commits
mailing list