[LNT] r263878 - [profile] Add support for importing profiles from a report
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 19 07:46:30 PDT 2016
Author: jamesm
Date: Sat Mar 19 09:46:30 2016
New Revision: 263878
URL: http://llvm.org/viewvc/llvm-project?rev=263878&view=rev
Log:
[profile] Add support for importing profiles from a report
This adds the necessary plumbing to ensure a profile attached to a JSON report will find its way into the profiles directory. Profiles are base64 encoded (with the Profile.render method) and placed directly in the report, just like a hash. But bigger.
Added:
lnt/trunk/tests/server/db/ImportProfile.py
lnt/trunk/tests/server/db/Inputs/profile-report.json
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=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/testsuitedb.py (original)
+++ lnt/trunk/lnt/server/db/testsuitedb.py Sat Mar 19 09:46:30 2016
@@ -344,7 +344,7 @@ class TestSuiteDB(object):
p = profile.Profile.fromRendered(encoded)
if config is not None:
self.filename = p.save(profileDir=config.config.profileDir,
- prefix='t-%s-s-' % testid)
+ prefix='t-%s-s-' % os.path.basename(testid))
s = ','.join('%s=%s' % (k,v)
for k,v in p.getTopLevelCounters().items())
@@ -793,7 +793,7 @@ supplied run is missing required run par
return run,True
- def _importSampleValues(self, tests_data, run, tag, commit):
+ def _importSampleValues(self, tests_data, run, tag, commit, config):
# We now need to transform the old schema data (composite samples split
# into multiple tests with mangling) into the V4DB format where each
# sample is a complete record.
@@ -834,20 +834,25 @@ test %r is misnamed for reporting under
# values, which we cannot properly aggregate. We handle this by keying
# off of the test name and the sample index.
sample_records = {}
+ profiles = {}
for name,test_samples in tests_values.items():
# Map this reported test name into a test name and a sample field.
#
# FIXME: This is really slow.
- for item in self.sample_fields:
- if name.endswith(item.info_key):
- test_name = name[:-len(item.info_key)]
- sample_field = item
- break
+ if name.endswith('.profile'):
+ test_name = name[:-len('.profile')]
+ sample_field = 'profile'
else:
- # Disallow tests which do not map to a sample field.
- raise ValueError,"""\
-test %r does not map to a sample field in the reported suite""" % (
- name)
+ for item in self.sample_fields:
+ if name.endswith(item.info_key):
+ test_name = name[:-len(item.info_key)]
+ sample_field = item
+ break
+ else:
+ # Disallow tests which do not map to a sample field.
+ raise ValueError,"""\
+ test %r does not map to a sample field in the reported suite""" % (
+ name)
# Get or create the test.
test = test_cache.get(test_name)
@@ -862,7 +867,12 @@ test %r does not map to a sample field i
sample_records[record_key] = sample = self.Sample(run, test)
self.add(sample)
- sample.set_field(sample_field, value)
+ if sample_field != 'profile':
+ sample.set_field(sample_field, value)
+ else:
+ sample.profile = profiles.get(hash(value),
+ self.Profile(value, config,
+ test_name))
def importDataFromDict(self, data, commit, config=None):
"""
@@ -889,7 +899,7 @@ test %r does not map to a sample field i
if not inserted:
return False, run
- self._importSampleValues(data['Tests'], run, tag, commit)
+ self._importSampleValues(data['Tests'], run, tag, commit, config)
return True, run
Added: lnt/trunk/tests/server/db/ImportProfile.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/ImportProfile.py?rev=263878&view=auto
==============================================================================
--- lnt/trunk/tests/server/db/ImportProfile.py (added)
+++ lnt/trunk/tests/server/db/ImportProfile.py Sat Mar 19 09:46:30 2016
@@ -0,0 +1,17 @@
+# Check that we can import profiles into a test DB
+#
+# We first construct a temporary LNT instance.
+# RUN: rm -rf %t.install
+# RUN: lnt create %t.install
+
+# Import the test set
+# RUN: lnt import %t.install %S/Inputs/profile-report.json \
+# RUN: --commit=1 --show-sample-count > %t2.log
+# RUN: ls %t.install/data/profiles
+# RUN: python %s %t.install
+
+import os, sys, glob
+from lnt.testing.profile.profilev1impl import ProfileV1
+
+profile = glob.glob('%s/data/profiles/*.lntprof' % sys.argv[1])[0]
+assert ProfileV1.checkFile(profile)
Added: lnt/trunk/tests/server/db/Inputs/profile-report.json
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/Inputs/profile-report.json?rev=263878&view=auto
==============================================================================
--- lnt/trunk/tests/server/db/Inputs/profile-report.json (added)
+++ lnt/trunk/tests/server/db/Inputs/profile-report.json Sat Mar 19 09:46:30 2016
@@ -0,0 +1,68 @@
+{
+ "Machine": {
+ "Info": {},
+ "Name": "e105293.local__clang_DEV__x86_64"
+ },
+ "Run": {
+ "End Time": "2016-03-14 14:20:29",
+ "Info": {
+ "__report_version__": "1",
+ "cc1_exec_hash": "c431213c8e77728ee825579745d700e79c3521f2",
+ "cc_alt_src_branch": "llvm/trunk",
+ "cc_alt_src_revision": "154329",
+ "cc_as_version": "unrecognized argument vector: ('-c', '-Wa,-v', '-o', '/dev/null', '-x', 'assembler', '/dev/null')",
+ "cc_build": "DEV",
+ "cc_dumpmachine": "x86_64-apple-darwin11.0.0",
+ "cc_exec_hash": "c431213c8e77728ee825579745d700e79c3521f2",
+ "cc_ld_version": "unrecognized argument vector: ('-Wl,-v', '-o', '/dev/null', '/tmp/tmpzWa737.c')",
+ "cc_name": "clang",
+ "cc_src_branch": "trunk",
+ "cc_src_revision": "154331",
+ "cc_target": "x86_64-apple-darwin11.0.0",
+ "cc_target_assembly": "; ModuleID = '/dev/null'\ntarget datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"\ntarget triple = \"x86_64-apple-darwin11.0.0\"",
+ "cc_version": "clang version 3.1 (trunk 154331) (llvm/trunk 154329)\nTarget: x86_64-apple-darwin11.3.0\nThread model: posix\nInstalledDir: /home/foo/bin\n\n \"/Users/jammol01/Code/lnt/tests/SharedInputs/FakeCompilers/clang-r154331\" \"-cc1\" \"-E\" ... more boring stuff here ...",
+ "cc_version_number": "3.1",
+ "inferred_run_order": "154331",
+ "run_order": "154331",
+ "tag": "nts"
+ },
+ "Start Time": "2016-03-14 14:20:28"
+ },
+ "Tests": [
+ {
+ "Data": [
+ 1.4
+ ],
+ "Info": {},
+ "Name": "nts.foo.exec"
+ },
+ {
+ "Data": [
+ 1.3
+ ],
+ "Info": {},
+ "Name": "nts.foo.compile"
+ },
+ {
+ "Data": [
+ 1.5
+ ],
+ "Info": {},
+ "Name": "nts.foo.score"
+ },
+ {
+ "Data": [
+ "xyz"
+ ],
+ "Info": {},
+ "Name": "nts.foo.hash"
+ },
+ {
+ "Data": [
+ "eJxNj8EOgjAMhu99Cm9wULMOEHgBE888QdkASWCQFWJ8e1v04JIt+9f//7qmfkVoEj8yMXdzO70v/RJn2hJYrRQiveSWATdJvwe3jUtgecgh9Wsh9T6gyJvKUjm0kegK0mmt9UCjJUSgB5q8KsobUJOQ96dozr8tAbRApPbssOeCcm83ddoLC7ijMcA/RGUUwXt7iviPEDLJN92yh62LR7I8aBUMysgLnaKNFNzzMo8y7uGplQ4sa/j6rfn60WYaGdRhtT9fP5+JUW4="
+ ],
+ "Info": {},
+ "Name": "nts.foo.profile"
+ }
+ ]
+}
More information about the llvm-commits
mailing list