Skip to content
Snippets Groups Projects
Commit 50b8748d authored by Daniel Silverstone's avatar Daniel Silverstone
Browse files

_yaml.py: Only retrieve provenance in node_get() when needed


We were indiscriminately retrieving the node's provenance data in the
`node_get()` function which was accounting for approximately a third of
the total runtime of `node_get()` which dominates pre-scheduler time in
`bst build`.  This change ameliorates that situation by only retrieving
the provenance data when it's actually needed.

Signed-off-by: default avatarDaniel Silverstone <daniel.silverstone@codethink.co.uk>
parent 4d6e2cd3
No related branches found
No related tags found
1 merge request!933WIP: Some more microoptimisations
...@@ -364,8 +364,8 @@ _sentinel = object() ...@@ -364,8 +364,8 @@ _sentinel = object()
# #
def node_get(node, expected_type, key, indices=None, default_value=_sentinel): def node_get(node, expected_type, key, indices=None, default_value=_sentinel):
value = node.get(key, default_value) value = node.get(key, default_value)
provenance = node_get_provenance(node)
if value is _sentinel: if value is _sentinel:
provenance = node_get_provenance(node)
raise LoadError(LoadErrorReason.INVALID_DATA, raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: Dictionary did not contain expected key '{}'".format(provenance, key)) "{}: Dictionary did not contain expected key '{}'".format(provenance, key))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment