[LNT] r349219 - Make a cache for machine -> order lookup
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 16:34:03 PST 2018
Author: cmatthews
Date: Fri Dec 14 16:34:03 2018
New Revision: 349219
URL: http://llvm.org/viewvc/llvm-project?rev=349219&view=rev
Log:
Make a cache for machine -> order lookup
This set of queries were taking a long time. Make the query faster,
by using .first(), and then cache the results in our testsuitedb.
Modified:
lnt/trunk/lnt/server/db/regression.py
lnt/trunk/lnt/server/db/testsuitedb.py
Modified: lnt/trunk/lnt/server/db/regression.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/regression.py?rev=349219&r1=349218&r2=349219&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/regression.py (original)
+++ lnt/trunk/lnt/server/db/regression.py Fri Dec 14 16:34:03 2018
@@ -87,6 +87,14 @@ def get_all_orders_for_machine(session,
.order_by(asc(ts.Order.llvm_project_revision)) \
.all()
+ at timed
+def get_last_order_for_machine(session, ts, machine):
+ """Get all the orders for this sa machine."""
+ return session.query(ts.Order) \
+ .join(ts.Run) \
+ .filter(ts.Run.machine_id == machine) \
+ .order_by(desc(ts.Order.llvm_project_revision)) \
+ .first()
def get_ris(session, ts, regression_id):
return session.query(ts.RegressionIndicator) \
@@ -116,7 +124,10 @@ def get_current_runs_of_fieldchange(sess
before_runs = get_runs_for_order_and_machine(session, ts,
fc.start_order_id,
fc.machine_id)
- newest_order = get_all_orders_for_machine(session, ts, fc.machine_id)[-1]
+ newest_order = ts.machine_to_latest_order_cache.get(fc.machine_id)
+ if not newest_order:
+ newest_order = get_last_order_for_machine(session, ts, fc.machine_id)
+ ts.machine_to_latest_order_cache[fc.machine_id] = newest_order
after_runs = get_runs_for_order_and_machine(session, ts, newest_order.id,
fc.machine_id)
Modified: lnt/trunk/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/testsuitedb.py?rev=349219&r1=349218&r2=349219&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/testsuitedb.py (original)
+++ lnt/trunk/lnt/server/db/testsuitedb.py Fri Dec 14 16:34:03 2018
@@ -88,6 +88,7 @@ class TestSuiteDB(object):
self.run_fields = list(self.test_suite.run_fields)
self.sample_fields = list(sorted(self.test_suite.sample_fields,
key = lambda s: s.schema_index))
+ self.machine_to_latest_order_cache = {}
sample_field_indexes = dict()
for i, field in enumerate(self.sample_fields):
More information about the llvm-commits
mailing list