[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#903108: python-apt: Please provide native filter API for pkg.is_auto_removable and pkg.is_upgradable



Package: python-apt
Version: 1.0.1
Severity: wishlist

Dear Maintainers,

Unattended-upgrades needs to find all upgradable and autoremovable
packages, but the filtering itself happens in Python code making it
slow - and a very significant part of u-u's CPU time starting with u-u
1.4 (~60% when there is nothing to install):

$ python3 -c "import timeit; print(timeit.timeit(stmt='{pkg.name for
pkg in cache if pkg.is_upgradable}', setup='import apt;cache =
apt.Cache();gc.enable()',number=10)/10)"
0.703306365699973

$ sudo time ./unattended-upgrade  --verbose
Initial blacklisted packages:
Initial whitelisted packages:
Starting unattended upgrades script
Allowed origins are: o=Ubuntu,a=bionic, o=Ubuntu,a=bionic-security,
o=UbuntuESM,a=bionic
No packages found that can be upgraded unattended and no pending auto-removals
2.21user 0.09system 0:02.33elapsed 98%CPU (0avgtext+0avgdata 109296maxresident)k
0inputs+21072outputs (0major+28423minor)pagefaults 0swaps

I tried using FilteredCache, but as it filters in Python, too, it did
not speed up filtering and actually it made the code slower.

Please extend the API to provide filtering in native code (or just
much faster code) at least for .is_auto_removable and .is_upgradable.

Thanks,
Balint

-- 
Balint Reczey
Ubuntu & Debian Developer


Reply to: