[PATCH] D115702: [LNT] Fix profile assigning to tests

Pavel Kosov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 22:55:09 PST 2021


kpdev42 created this revision.
kpdev42 added reviewers: cmatthews, danilaml, thopre.
kpdev42 added a project: LLVM.
Herald added a subscriber: dkolesnichenko.
kpdev42 requested review of this revision.

report.json may contain the following content:

  “Tests”: [
  {“Data”: [ 123 ], “Name”: “nts.SomeTest.test:subTest1.exec”},
  {“Data”: [ 456 ], “Name”: “nts.SomeTest.test:subTest2.exec”},
  {“Data”: [ “base64_encoded_profile_data” ], “Name”: “nts.SomeTest.profile”}
  ]

This report.json contains 2 tests (execution_time) and 1 profile data which must be assigned to both tests.
Currently LNT creates 3 tests. First 2 tests do not have a profile data. 3rd test does not have any metric, but has the profile data.

This patch implements the correct processing such reports.

OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg


Repository:
  rLNT LNT

https://reviews.llvm.org/D115702

Files:
  lnt/server/db/testsuitedb.py
  lnt/testing/__init__.py


Index: lnt/testing/__init__.py
===================================================================
--- lnt/testing/__init__.py
+++ lnt/testing/__init__.py
@@ -485,6 +485,7 @@
         '.hash.status': 'hash_status',
         '.mem': 'mem_bytes',
         '.score': 'score',
+        '.profile': 'profile',
     }, machine_param_rename={
         'name': 'hostname',  # Avoid name clash with actual machine name.
     }, run_param_rename={
Index: lnt/server/db/testsuitedb.py
===================================================================
--- lnt/server/db/testsuitedb.py
+++ lnt/server/db/testsuitedb.py
@@ -1038,10 +1038,13 @@
         test_cache = dict((test.name, test)
                           for test in session.query(self.Test))
 
-        profiles = dict()
         field_dict = dict([(f.name, f) for f in self.sample_fields])
         all_samples_to_add = []
         for test_data in tests_data:
+            if len(test_data) == 2 and 'profile' in test_data:
+                # Ignore for now profile data without other metrics
+                continue
+
             name = test_data['name']
             test = test_cache.get(name)
             if test is None:
@@ -1066,10 +1069,42 @@
                     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)
+                        sample.profile = self.Profile(value, config, name)
                     else:
                         sample.set_field(field, value)
+
+        for test_data in tests_data:
+            if len(test_data) != 2 or 'profile' not in test_data:
+                continue
+            name = test_data['name']
+            test = test_cache.get(name)
+            tests = [test_cache[test_name] for test_name in test_cache \
+                                           if test_name.startswith(name + '.test:')]
+            if test is not None:
+                tests.append(test)
+
+            value = test_data['profile']
+            new_profile = self.Profile(value, config, name)
+            count = 0
+            for test in tests:
+                sample_exist = False
+                for sample in all_samples_to_add:
+                    if sample.test == test:
+                        if sample.profile is None:
+                            sample.profile = new_profile
+                            count += 1
+                            sample_exist = True
+                        else:
+                            logger.warning('Test %s already contains the profile data. ' \
+                                'Profile %s was ignored.', test.name, name)
+                if not sample_exist:
+                    logger.warning('The test %s is invalid. It contains the profile, ' \
+                                   'but no any samples. Consider removing it.', test.name)
+            if count == 0:
+                logger.warning('Cannot find test(s) for the profile %s', name)
+            else:
+                logger.info('The profile %s was added to %d test(s).', name, count)
+
         session.add_all(all_samples_to_add)
 
     def importDataFromDict(self, session, data, config, select_machine,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115702.394147.patch
Type: text/x-patch
Size: 3357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211214/04117493/attachment.bin>


More information about the llvm-commits mailing list