Merge ~mdeslaur/ubuntu-cve-tracker:perf into ubuntu-cve-tracker:master

Proposed by Marc Deslauriers
Status: Merged
Merged at revision: 4ac7810a4cb2b10c97bbeae76a69535989d870d0
Proposed branch: ~mdeslaur/ubuntu-cve-tracker:perf
Merge into: ubuntu-cve-tracker:master
Diff against target: 55 lines (+19/-8)
1 file modified
scripts/check-syntax (+19/-8)
Reviewer Review Type Date Requested Status
Steve Beattie Approve
Review via email: mp+461547@code.launchpad.net

Commit message

check-syntax: build up aliases cache once

Build up an aliases cache once, instead of performaing expensive
operations while processing each CVE. This dramatically reduces
the time required for check-syntax.

Description of the change

BEFORE:

$ time ./scripts/check-syntax -j8

real 3m12.768s
user 22m34.429s
sys 2m57.485s

AFTER:

$ time ./scripts/check-syntax -j8

real 2m22.853s
user 15m49.636s
sys 2m59.093s

To post a comment you must log in.
Revision history for this message
Steve Beattie (sbeattie) wrote :

Nice, lgtm. Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/check-syntax b/scripts/check-syntax
2index 5d476b0..b740331 100755
3--- a/scripts/check-syntax
4+++ b/scripts/check-syntax
5@@ -130,15 +130,26 @@ def is_unpublished_kernel(kernel, release=None, debug=False):
6 return True
7 return False
8
9-def get_pkgs_from_aliases(sources, aliases, pkg, rel):
10+def build_aliases_cache(sources):
11+ rev_aliases = {}
12+
13+ for rel in sources:
14+ for pkg in sources[rel]:
15+ if 'aliases' in sources[rel][pkg]:
16+ for alias in sources[rel][pkg]['aliases']:
17+ if rel not in rev_aliases:
18+ rev_aliases[rel] = {}
19+ if alias not in rev_aliases[rel]:
20+ rev_aliases[rel][alias] = []
21+ rev_aliases[rel][alias].append(pkg)
22+
23+ return rev_aliases
24+
25+def get_pkgs_from_aliases(aliases, pkg, rel):
26 if rel in aliases:
27 if pkg in aliases[rel]:
28 return aliases[rel][pkg]
29- else:
30- aliases[rel] = {}
31-
32- aliases[rel][pkg] = source_map.get_aliases_of_ubuntu_package(sources, pkg, rel)
33- return aliases[rel][pkg]
34+ return []
35
36 def subprocess_setup():
37 # Python installs a SIGPIPE handler by default. This is usually not what
38@@ -405,7 +416,7 @@ if len(cna_cves_set) > 0 and all_files:
39 print("%s: %d: %s that we assigned needs an UCT entry.\n"
40 % (cna_cves_set[cve][0], cna_cves_set[cve][1], cve))
41
42-aliases_cache = {}
43+aliases_cache = build_aliases_cache(source)
44
45 def fixup_entry(filename, pkg, rel):
46 # If release is devel or EOL, we should add the proper status instead of removing
47@@ -613,7 +624,7 @@ def check_cve(cve):
48
49 if not skip_aliases:
50 aliases = False
51- pkgs_from_aliases = get_pkgs_from_aliases(source, aliases_cache, pkg, rel)
52+ pkgs_from_aliases = get_pkgs_from_aliases(aliases_cache, pkg, rel)
53 if pkgs_from_aliases:
54 aliases = True
55 aliases_releases.add(rel)

Subscribers

People subscribed via source and target branches