Project

Profile

Help

Issue #2362

closed

applicability calculation wastes time scanning a list

Added by mhrivnak over 7 years ago. Updated about 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Assignee:
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
2.8.7
Platform Release:
2.10.3
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Sprint 9
Quarter:

Description

Applicability calculation for errata spends most of its time scanning a large list of dicts to see if it contains a particular dict. Profiling shows that a normal applicability task spends about 95% of its time scanning this list. This is causing calculation to take much longer than is reasonably expected.

Considering a RHEL 6 repo with approximately 18000 rpms and 3700 errata, pulp does this:

make a list of dicts, each representing one rpm
for each errata:
  for each rpm listed in the errata:
    check if the rpm is in the list of dicts

The query happens here:

https://github.com/pulp/pulp_rpm/blob/pulp-rpm-2.8.7-1/plugins/pulp_rpm/plugins/profilers/yum.py#L321

Profiling with cProfile showed that out of 81 seconds spent calculating applicability (both rpm and errata) for one consumer, 77 of those seconds were spent on this activity. The list was scanned more than 80000 times.

It should instead use a better data structure, like a set, that is optimized to perform membership queries in constant time.

Also available in: Atom PDF