为什么 apt-cache 这么慢?

Dam*_*nal 5 apt 14.04

从 Saucy (13.10) 升级到 Trusty (14.04) 后,所有 apt 操作都很慢。即使是那些不包括下载任何内容或连接到任何服务器的内容。例如,显示 apt 策略

# time apt-cache policy 

[...]

real    0m8.951s
user    0m5.069s
sys     0m3.861s
Run Code Online (Sandbox Code Playgroud)

几乎需要十秒钟!发出命令后主要是一个奇怪的滞后。即使我再次发出相同的命令,它也是一样的。

在另一个系统上不需要十分之一秒

real    0m0.096s
user    0m0.070s
sys     0m0.023s
Run Code Online (Sandbox Code Playgroud)

另一个系统更强大,但升级前没有明显差异。

apt-get 也是一样,任何与 apt 相关的东西。我如何找出这种滞后的来源并解决它?

附加信息:

# cat /etc/nsswitch.conf 

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我对 apt-cache 工作原理的理解是正确的吗?当我运行时它不会建立任何网络连接apt-cache policy,对吗?

如果我错了,这很重要,这里是我的来源https://gist.github.com/anonymous/02920270ff68e23fc3ec

Bra*_*ask 5

打开终端并首先安装漂白位

sudo apt-get install bleachbit
Run Code Online (Sandbox Code Playgroud)

然后以 sudo 身份运行漂白位:

sudo bleachbit
Run Code Online (Sandbox Code Playgroud)

然后执行清理,你会看到事情开始变得更快:)


tot*_*tti 1

根据我的经验,如果 apt 已知的软件包数量非常多,那么 apt 操作的延迟是很自然的。要知道运行的包数量apt-cache stats。在两台计算机上执行此操作并显示输出。
考虑以下情况。从 live iso(位于 HDD 中)启动后,apt 操作apt-get install只需不到一秒的时间。apt 已知的软件包数量约为 7k。添加一些软件源(例如来自 Universe 的软件包)后,main apt 知道约 50k 软件包。现在该命令apt-get install需要大约 9 秒(构建依赖树等)。现在缓存大小约为 60 MB


小智 0

我注意到,现在我使用突触包管理器,卸载软件中心和应用程序安装数据可以大大加快 apt 缓存的速度...