Jonathan Maw pushed to branch jonathan/faster-except-elements at BuildStream / buildstream
Commits:
-
f1a619b5
by Jonathan Maw at 2018-08-20T16:34:03Z
-
ba74a128
by Jonathan Maw at 2018-08-20T17:53:33Z
-
18acd3ea
by Valentin David at 2018-08-21T08:44:34Z
-
6bd688cf
by Valentin David at 2018-08-21T08:44:34Z
-
4cab18e3
by Qinusty at 2018-08-21T09:38:39Z
-
f3fbdac0
by Jonathan Maw at 2018-08-21T11:33:34Z
6 changed files:
- buildstream/_artifactcache/cascache.py
- buildstream/_includes.py
- buildstream/_loader/loader.py
- buildstream/_pipeline.py
- buildstream/_project.py
- buildstream/source.py
Changes:
... | ... | @@ -318,7 +318,7 @@ class CASCache(ArtifactCache): |
318 | 318 |
resource_name = '/'.join(['uploads', str(uuid_), 'blobs',
|
319 | 319 |
digest.hash, str(digest.size_bytes)])
|
320 | 320 |
|
321 |
- def request_stream():
|
|
321 |
+ def request_stream(resname):
|
|
322 | 322 |
with open(self.objpath(digest), 'rb') as f:
|
323 | 323 |
assert os.fstat(f.fileno()).st_size == digest.size_bytes
|
324 | 324 |
offset = 0
|
... | ... | @@ -332,12 +332,12 @@ class CASCache(ArtifactCache): |
332 | 332 |
request.write_offset = offset
|
333 | 333 |
# max. 64 kB chunks
|
334 | 334 |
request.data = f.read(chunk_size)
|
335 |
- request.resource_name = resource_name # pylint: disable=cell-var-from-loop
|
|
335 |
+ request.resource_name = resname
|
|
336 | 336 |
request.finish_write = remaining <= 0
|
337 | 337 |
yield request
|
338 | 338 |
offset += chunk_size
|
339 | 339 |
finished = request.finish_write
|
340 |
- response = remote.bytestream.Write(request_stream())
|
|
340 |
+ response = remote.bytestream.Write(request_stream(resource_name))
|
|
341 | 341 |
|
342 | 342 |
request = buildstream_pb2.UpdateReferenceRequest()
|
343 | 343 |
request.keys.append(ref)
|
... | ... | @@ -10,11 +10,15 @@ from ._exceptions import LoadError, LoadErrorReason |
10 | 10 |
#
|
11 | 11 |
# Args:
|
12 | 12 |
# loader (Loader): The Loader object
|
13 |
+# copy_tree (bool): Whether to make a copy, of tree in
|
|
14 |
+# provenance. Should be true if intended to be
|
|
15 |
+# serialized.
|
|
13 | 16 |
class Includes:
|
14 | 17 |
|
15 |
- def __init__(self, loader):
|
|
18 |
+ def __init__(self, loader, *, copy_tree=False):
|
|
16 | 19 |
self._loader = loader
|
17 | 20 |
self._loaded = {}
|
21 |
+ self._copy_tree = copy_tree
|
|
18 | 22 |
|
19 | 23 |
# process()
|
20 | 24 |
#
|
... | ... | @@ -96,10 +100,11 @@ class Includes: |
96 | 100 |
directory = project.directory
|
97 | 101 |
file_path = os.path.join(directory, include)
|
98 | 102 |
key = (current_loader, file_path)
|
99 |
- if file_path not in self._loaded:
|
|
103 |
+ if key not in self._loaded:
|
|
100 | 104 |
self._loaded[key] = _yaml.load(os.path.join(directory, include),
|
101 | 105 |
shortname=shortname,
|
102 |
- project=project)
|
|
106 |
+ project=project,
|
|
107 |
+ copy_tree=self._copy_tree)
|
|
103 | 108 |
return self._loaded[key], file_path, current_loader
|
104 | 109 |
|
105 | 110 |
# _process_value()
|
... | ... | @@ -78,7 +78,7 @@ class Loader(): |
78 | 78 |
self._elements = {} # Dict of elements
|
79 | 79 |
self._loaders = {} # Dict of junction loaders
|
80 | 80 |
|
81 |
- self._includes = Includes(self)
|
|
81 |
+ self._includes = Includes(self, copy_tree=True)
|
|
82 | 82 |
|
83 | 83 |
# load():
|
84 | 84 |
#
|
... | ... | @@ -235,6 +235,9 @@ class Pipeline(): |
235 | 235 |
# exceptions removed
|
236 | 236 |
#
|
237 | 237 |
def except_elements(self, targets, elements, except_targets):
|
238 |
+ if not except_targets:
|
|
239 |
+ return elements
|
|
240 |
+ |
|
238 | 241 |
targeted = list(self.dependencies(targets, Scope.ALL))
|
239 | 242 |
visited = []
|
240 | 243 |
|
... | ... | @@ -419,7 +419,7 @@ class Project(): |
419 | 419 |
parent=parent_loader,
|
420 | 420 |
tempdir=tempdir)
|
421 | 421 |
|
422 |
- self._project_includes = Includes(self.loader)
|
|
422 |
+ self._project_includes = Includes(self.loader, copy_tree=False)
|
|
423 | 423 |
|
424 | 424 |
project_conf_first_pass = _yaml.node_copy(self._project_conf)
|
425 | 425 |
self._project_includes.process(project_conf_first_pass, only_local=True)
|
... | ... | @@ -794,7 +794,7 @@ class Source(Plugin): |
794 | 794 |
# Save the ref in the originating file
|
795 | 795 |
#
|
796 | 796 |
try:
|
797 |
- _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name)
|
|
797 |
+ _yaml.dump(provenance.toplevel, provenance.filename.name)
|
|
798 | 798 |
except OSError as e:
|
799 | 799 |
raise SourceError("{}: Error saving source reference to '{}': {}"
|
800 | 800 |
.format(self, provenance.filename.name, e),
|