Improve performance in pmb.helpers.pmaports find package
I've noticed that finding packages in our pmaports folder got very slow lately, so I decided to investigate.
For analyzing I've added a global variable to sum all the time spent in the find
method of pmb.helpers.pmaports.py
, which is called many times during pmb.chroot.apk.install()
I've just used the pmbootstrap qemu
command which installs all the required packages before starting (device: qemu-amd64, ui: gnome)
Total time: ~17 seconds
I've separated the improvements in 3 different commits:
-
Cache the results of the
_glob_apkbuilds
method (with*
returns the list of paths of all the packages). This reduced the total time to ~8 seconds -
Before looking for the package APKBUILD path, check if the package exists. This reduced the total time to ~1 second
-
The last commit caches the result of the
get_list
method (which returns the list of packages). This reduced the total time to ~0.6 seconds
I think it's quite a big performance gain from 17 to 0.6 seconds