[Bug 1713219] Re: 'apt-mark showauto' and 'apt-cache show' is slow
Jarno Suni
1713219 at bugs.launchpad.net
Sat Apr 10 07:07:13 UTC 2021
** Description changed:
$ time apt-mark showauto >/dev/null
real 0m0,620s
user 0m0,557s
sys 0m0,052s
When I run the command first time, it is even much slower.
- I could do the job* in fraction of a time using awk in POSIX shell script
- (name it ./apt-mark-showauto.sh):
+ I could do the job* in fraction of a time using an AWK script
+ (name it ./apt-mark-showauto.awk):
- #!/bin/sh
- auto_file='/var/lib/apt/extended_states'
- awk '/^Package:/ {
- pkg=$2
- while (getline > 0 && $0) {
- if ($1 == "Auto-Installed:") {
- if ($2==1) print pkg
- break
- }
+ #!/usr/bin/awk -f
+ BEGIN{
+ file="/var/lib/apt/extended_states"
+ while ((getline < file) > 0) {
+ if ($0 ~ /^Package:/) {
+ pkg=$2
+ while ((getline < file) > 0 && $0) {
+ if ($1 == "Auto-Installed:") {
+ if ($2==1) print pkg
+ break
+ }
+ }
+ }
}
- }' "$auto_file"
+ }
- $ time ./apt-mark-showauto.sh >/dev/null
+ $ time ./apt-mark-showauto.awk >/dev/null
- real 0m0,005s
- user 0m0,002s
- sys 0m0,004s
+ real 0m0,004s
+ user 0m0,004s
+ sys 0m0,000s
- Tested in Ubuntu 20.04.
+ Tested in Ubuntu 20.04 and mawk 1.3.4 as AWK interpreter.
*) The script omits Architecture information, though. And should apt-
config be queried for the extended_states file path?
Similarly
apt-cache show <pkg>
is slow. (It also shows whether a package is manually or automatically
installed.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: apt 1.0.1ubuntu2.17
ProcVersionSignature: Ubuntu 4.4.0-92.115~14.04.1-generic 4.4.76
Uname: Linux 4.4.0-92-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.25
Architecture: amd64
CurrentDesktop: XFCE
Date: Sat Aug 26 12:59:00 2017
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-09-21 (1070 days ago)
InstallationMedia: Ubuntu-Studio 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.1)
SourcePackage: apt
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.cron.daily.apt: [modified]
modified.conffile..etc.kernel.postinst.d.apt.auto.removal: [modified]
mtime.conffile..etc.cron.daily.apt: 2017-05-03T10:27:27.617839
mtime.conffile..etc.kernel.postinst.d.apt.auto.removal: 2017-06-01T14:39:39.236080
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to apt in Ubuntu.
https://bugs.launchpad.net/bugs/1713219
Title:
'apt-mark showauto' and 'apt-cache show' is slow
Status in apt package in Ubuntu:
Triaged
Bug description:
$ time apt-mark showauto >/dev/null
real 0m0,620s
user 0m0,557s
sys 0m0,052s
When I run the command first time, it is even much slower.
I could do the job* in fraction of a time using an AWK script
(name it ./apt-mark-showauto.awk):
#!/usr/bin/awk -f
BEGIN{
file="/var/lib/apt/extended_states"
while ((getline < file) > 0) {
if ($0 ~ /^Package:/) {
pkg=$2
while ((getline < file) > 0 && $0) {
if ($1 == "Auto-Installed:") {
if ($2==1) print pkg
break
}
}
}
}
}
$ time ./apt-mark-showauto.awk >/dev/null
real 0m0,004s
user 0m0,004s
sys 0m0,000s
Tested in Ubuntu 20.04 and mawk 1.3.4 as AWK interpreter.
*) The script omits Architecture information, though. And should apt-
config be queried for the extended_states file path?
Similarly
apt-cache show <pkg>
is slow. (It also shows whether a package is manually or automatically
installed.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: apt 1.0.1ubuntu2.17
ProcVersionSignature: Ubuntu 4.4.0-92.115~14.04.1-generic 4.4.76
Uname: Linux 4.4.0-92-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.25
Architecture: amd64
CurrentDesktop: XFCE
Date: Sat Aug 26 12:59:00 2017
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-09-21 (1070 days ago)
InstallationMedia: Ubuntu-Studio 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.1)
SourcePackage: apt
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.cron.daily.apt: [modified]
modified.conffile..etc.kernel.postinst.d.apt.auto.removal: [modified]
mtime.conffile..etc.cron.daily.apt: 2017-05-03T10:27:27.617839
mtime.conffile..etc.kernel.postinst.d.apt.auto.removal: 2017-06-01T14:39:39.236080
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1713219/+subscriptions
More information about the foundations-bugs
mailing list