manatools / dnfdaemon

DBus daemon for doing package action with the dnf package manager
GNU General Public License v2.0
12 stars 16 forks source link

Reduce duration of loading cache #43

Closed papoteur-mga closed 3 years ago

papoteur-mga commented 3 years ago

In my tests with profiling, using yappi and valgrind, I see that in get_packages from server/init.py, 35% of the time is consumed in _get_po_list which is called for each package (27 000 in my case). The first improvement is in _get_id function. Initially, this function prepares a set, then appends the last value according to a test. Now, the whole is declared according to the result of the test. The second improvement is a conditional test on the fields to return from the GetPackages call. If the set of fields is ['summary', 'size', 'group'], I call a specific function get_packages_ndsg which return directly the attributes without testing them.

Now the improvement is about 20% of the the duration of loading cache.