[placement] Avoid rp.get_by_uuid in allocation_candidates
We already have a fully loaded resource provider object in the loop, so we don't need to create another one. Doing so has a very large performance impact, especially when there are many resource providers in the collection of summaries (which will be true in a large and sparsely used cloud). The code which creates the summaries used here as a data source has the same expensive use of get_by_uuid in a loop. That will be fixed in a separate patch. Existing functional tests cover this code. Change-Id: I6068db78240c33a1dcefedc0c94e76740fd8d6e2 Partial-Bug: #1786055
This commit is contained in:
parent
c52c2caf97
commit
3c96ce9158
|
@ -3516,11 +3516,9 @@ def _alloc_candidates_multiple_providers(ctx, requested_resources,
|
|||
|
||||
for rp_id, root_id, rc_id in rp_tuples:
|
||||
rp_summary = summaries[rp_id]
|
||||
rp_uuid = rp_summary.resource_provider.uuid
|
||||
tree_dict[root_id][rc_id].append(
|
||||
AllocationRequestResource(
|
||||
ctx, resource_provider=ResourceProvider.get_by_uuid(ctx,
|
||||
rp_uuid),
|
||||
ctx, resource_provider=rp_summary.resource_provider,
|
||||
resource_class=_RC_CACHE.string_from_id(rc_id),
|
||||
amount=requested_resources[rc_id]))
|
||||
|
||||
|
|
Loading…
Reference in New Issue