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
diff --git a/scripts/check-syntax b/scripts/check-syntax
index 5d476b0..b740331 100755
--- a/scripts/check-syntax
+++ b/scripts/check-syntax
@@ -130,15 +130,26 @@ def is_unpublished_kernel(kernel, release=None, debug=False):
130 return True130 return True
131 return False131 return False
132132
133def get_pkgs_from_aliases(sources, aliases, pkg, rel):133def build_aliases_cache(sources):
134 rev_aliases = {}
135
136 for rel in sources:
137 for pkg in sources[rel]:
138 if 'aliases' in sources[rel][pkg]:
139 for alias in sources[rel][pkg]['aliases']:
140 if rel not in rev_aliases:
141 rev_aliases[rel] = {}
142 if alias not in rev_aliases[rel]:
143 rev_aliases[rel][alias] = []
144 rev_aliases[rel][alias].append(pkg)
145
146 return rev_aliases
147
148def get_pkgs_from_aliases(aliases, pkg, rel):
134 if rel in aliases:149 if rel in aliases:
135 if pkg in aliases[rel]:150 if pkg in aliases[rel]:
136 return aliases[rel][pkg]151 return aliases[rel][pkg]
137 else:152 return []
138 aliases[rel] = {}
139
140 aliases[rel][pkg] = source_map.get_aliases_of_ubuntu_package(sources, pkg, rel)
141 return aliases[rel][pkg]
142153
143def subprocess_setup():154def subprocess_setup():
144 # Python installs a SIGPIPE handler by default. This is usually not what155 # Python installs a SIGPIPE handler by default. This is usually not what
@@ -405,7 +416,7 @@ if len(cna_cves_set) > 0 and all_files:
405 print("%s: %d: %s that we assigned needs an UCT entry.\n"416 print("%s: %d: %s that we assigned needs an UCT entry.\n"
406 % (cna_cves_set[cve][0], cna_cves_set[cve][1], cve))417 % (cna_cves_set[cve][0], cna_cves_set[cve][1], cve))
407418
408aliases_cache = {}419aliases_cache = build_aliases_cache(source)
409420
410def fixup_entry(filename, pkg, rel):421def fixup_entry(filename, pkg, rel):
411 # If release is devel or EOL, we should add the proper status instead of removing422 # If release is devel or EOL, we should add the proper status instead of removing
@@ -613,7 +624,7 @@ def check_cve(cve):
613624
614 if not skip_aliases:625 if not skip_aliases:
615 aliases = False626 aliases = False
616 pkgs_from_aliases = get_pkgs_from_aliases(source, aliases_cache, pkg, rel)627 pkgs_from_aliases = get_pkgs_from_aliases(aliases_cache, pkg, rel)
617 if pkgs_from_aliases:628 if pkgs_from_aliases:
618 aliases = True629 aliases = True
619 aliases_releases.add(rel)630 aliases_releases.add(rel)

Subscribers

People subscribed via source and target branches