[LNT] r349576 - Do bulk add to avoid DB round trips

Chris Matthews via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 15:39:24 PST 2018


Author: cmatthews
Date: Tue Dec 18 15:39:24 2018
New Revision: 349576

URL: http://llvm.org/viewvc/llvm-project?rev=349576&view=rev
Log:
Do bulk add to avoid DB round trips

Each add has to stage a sample, which leads to a SQL query and DB round
trip. For runs with a lot of sample, that can be avoided by adding them
all in one batch.

Modified:
    lnt/trunk/lnt/server/db/testsuitedb.py

Modified: lnt/trunk/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/testsuitedb.py?rev=349576&r1=349575&r2=349576&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/testsuitedb.py (original)
+++ lnt/trunk/lnt/server/db/testsuitedb.py Tue Dec 18 15:39:24 2018
@@ -1016,6 +1016,7 @@ class TestSuiteDB(object):
 
         profiles = dict()
         field_dict = dict([(f.name, f) for f in self.sample_fields])
+        all_samples_to_add = []
         for test_data in tests_data:
             name = test_data['name']
             test = test_cache.get(name)
@@ -1037,14 +1038,15 @@ class TestSuiteDB(object):
                     values = [values]
                 while len(samples) < len(values):
                     sample = self.Sample(run, test)
-                    session.add(sample)
                     samples.append(sample)
+                    all_samples_to_add.append(sample)
                 for sample, value in zip(samples, values):
                     if key == 'profile':
                         profile = self.Profile(value, config, name)
                         sample.profile = profiles.get(hash(value), profile)
                     else:
                         sample.set_field(field, value)
+        session.add_all(all_samples_to_add)
 
     def importDataFromDict(self, session, data, config, select_machine,
                            merge_run):




More information about the llvm-commits mailing list