aboutsummaryrefslogtreecommitdiff
path: root/lnt/server
diff options
context:
space:
mode:
authorChris Matthews <cmatthews5@apple.com>2018-12-11 18:47:44 +0000
committerChris Matthews <cmatthews5@apple.com>2018-12-11 18:47:44 +0000
commite0cb03c4e5f1d58256a3c60497a0030dacc08444 (patch)
tree2895bde6fc8c10a81a645aae9118c917dbb3a942 /lnt/server
parent08fa3c3a1ab7806f1732c6738d666e7a5b773795 (diff)
Don't call repr on all timed functions arguments
This was causing a huge amount of lazy loads from the database. git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@348877 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lnt/server')
-rw-r--r--lnt/server/db/fieldchange.py25
-rw-r--r--lnt/server/db/regression.py11
2 files changed, 22 insertions, 14 deletions
diff --git a/lnt/server/db/fieldchange.py b/lnt/server/db/fieldchange.py
index 9282ad7..8a23a87 100644
--- a/lnt/server/db/fieldchange.py
+++ b/lnt/server/db/fieldchange.py
@@ -120,6 +120,13 @@ def regenerate_fieldchanges_for_run(session, ts, run_id):
.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(session, ts, run_id):
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(session, ts, run_id):
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, fc):
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, fc):
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
diff --git a/lnt/server/db/regression.py b/lnt/server/db/regression.py
index 22bd366..f00b366 100644
--- a/lnt/server/db/regression.py
+++ b/lnt/server/db/regression.py
@@ -44,13 +44,18 @@ def new_regression(session, ts, field_changes):
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):