PCI tracker: make O(M * N) clean_usage algo linear
By using sets instead of lists we can cut the runtime of a piece of code that runs on every periodic resource update form quadratic to linear. Easy win. Change-Id: I7b0c1eb8188a428bf7e9f8dee710e9c46ed276eb
This commit is contained in:
parent
aac16b0257
commit
fc6442075a
|
@ -251,9 +251,9 @@ class PciDevTracker(object):
|
|||
|
||||
The caller should hold the COMPUTE_RESOURCE_SEMAPHORE lock
|
||||
"""
|
||||
existed = [inst['uuid'] for inst in instances]
|
||||
existed += [mig['instance_uuid'] for mig in migrations]
|
||||
existed += [inst['uuid'] for inst in orphans]
|
||||
existed = set(inst['uuid'] for inst in instances)
|
||||
existed |= set(mig['instance_uuid'] for mig in migrations)
|
||||
existed |= set(inst['uuid'] for inst in orphans)
|
||||
|
||||
for uuid in self.claims.keys():
|
||||
if uuid not in existed:
|
||||
|
|
Loading…
Reference in New Issue