summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKonrad Scherer <Konrad.Scherer@windriver.com>2019-09-27 14:56:42 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-10-02 20:22:25 +0100
commite1c173621a47112c034c447ea137531ea1af9031 (patch)
treefd08f3a9692234acabb063bc315b96298edd9806 /scripts
parent4148650475de8e1ec003acd53f75bd7000db7652 (diff)
downloadpoky-e1c173621a47112c034c447ea137531ea1af9031.tar.gz
gen-lockedsig-cache: Replace glob lookup with hash to filename lookup
Using the glob function to map signatures to sstate files is very slow when the sstate is large and accessed over nfs. The lookup now only loads the necessary prefixes and doesn't use glob as all. Unfortunately I don't have access to the systems where the performance isse was noticed and on my test system the glob is fast enough that the performance numbers aren't useful. I could verify that file list returned by the new code is the same. [YOCTO #13539] (From OE-Core rev: ad36335b8592e0387dd36066920cd5ffefd375f8) Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen-lockedsig-cache47
1 files changed, 42 insertions, 5 deletions
diff --git a/scripts/gen-lockedsig-cache b/scripts/gen-lockedsig-cache
index e3076e11a5..48cb67112f 100755
--- a/scripts/gen-lockedsig-cache
+++ b/scripts/gen-lockedsig-cache
@@ -5,9 +5,9 @@
5 5
6import os 6import os
7import sys 7import sys
8import glob
9import shutil 8import shutil
10import errno 9import errno
10import time
11 11
12def mkdir(d): 12def mkdir(d):
13 try: 13 try:
@@ -16,6 +16,36 @@ def mkdir(d):
16 if e.errno != errno.EEXIST: 16 if e.errno != errno.EEXIST:
17 raise e 17 raise e
18 18
19# extract the hash from past the last colon to last underscore
20def extract_sha(filename):
21 return filename.split(':')[7].split('_')[0]
22
23# get all files in a directory, extract hash and make
24# a map from hash to list of file with that hash
25def map_sha_to_files(dir_, prefix, sha_map):
26 sstate_prefix_path = dir_ + '/' + prefix + '/'
27 sstate_files = os.listdir(sstate_prefix_path)
28 for f in sstate_files:
29 try:
30 sha = extract_sha(f)
31 if sha not in sha_map:
32 sha_map[sha] = []
33 sha_map[sha].append(sstate_prefix_path + f)
34 except IndexError:
35 continue
36
37# given a prefix build a map of hash to list of files
38def build_sha_cache(prefix):
39 sha_map = {}
40
41 sstate_dir = sys.argv[2]
42 map_sha_to_files(sstate_dir, prefix, sha_map)
43
44 native_sstate_dir = sys.argv[2] + '/' + sys.argv[4]
45 map_sha_to_files(native_sstate_dir, prefix, sha_map)
46
47 return sha_map
48
19if len(sys.argv) < 5: 49if len(sys.argv) < 5:
20 print("Incorrect number of arguments specified") 50 print("Incorrect number of arguments specified")
21 print("syntax: gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir> <nativelsbstring> [filterfile]") 51 print("syntax: gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir> <nativelsbstring> [filterfile]")
@@ -41,12 +71,19 @@ with open(sys.argv[1]) as f:
41 sigs.append(sig) 71 sigs.append(sig)
42 72
43print('Gathering file list') 73print('Gathering file list')
74start_time = time.perf_counter()
44files = set() 75files = set()
76sstate_content_cache = {}
45for s in sigs: 77for s in sigs:
46 p = sys.argv[2] + "/" + s[:2] + "/*" + s + "*" 78 prefix = s[:2]
47 files |= set(glob.glob(p)) 79 if prefix not in sstate_content_cache:
48 p = sys.argv[2] + "/%s/" % sys.argv[4] + s[:2] + "/*" + s + "*" 80 sstate_content_cache[prefix] = build_sha_cache(prefix)
49 files |= set(glob.glob(p)) 81
82 for f in sstate_content_cache[prefix][s]:
83 files.add(f)
84
85elapsed = time.perf_counter() - start_time
86print("Gathering file list took %.1fs" % elapsed)
50 87
51print('Processing files') 88print('Processing files')
52for f in files: 89for f in files: