[Bug 1004947] Re: "apt-cache search" is slow because of listing /var/lib/apt/lists 45227 times

Daniel Hahler launchpad at thequod.de
Mon May 28 11:06:24 UTC 2012


When running it in gdb, I get the following backtrace:
Starting program: /usr/bin/apt-cache search apt
^C
Program received signal SIGINT, Interrupt.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdd424 in __kernel_vsyscall ()
#1  0xb7c9c70f in __getdents64 (fd=16304, buf=<optimized out>, nbytes=<optimized out>) at ../sysdeps/unix/sysv/linux/getdents.c:156
#2  0xb7c9c977 in __readdir64 (dirp=0x806d1d8) at ../sysdeps/unix/readdir.c:66
#3  0xb7f58d5a in APT::Configuration::getLanguages(bool const&, bool const&, char const**) () from /usr/lib/i386-linux-gnu/libapt-pkg.so.4.12
#4  0xb7edf650 in pkgCache::VerIterator::TranslatedDescription() const () from /usr/lib/i386-linux-gnu/libapt-pkg.so.4.12
#5  0x08051bd1 in Search (CmdL=...) at apt-cache.cc:1273
#6  0xb7ecaf6e in CommandLine::DispatchArg(CommandLine::Dispatch*, bool) () from /usr/lib/i386-linux-gnu/libapt-pkg.so.4.12
#7  0x0804e833 in main (argc=3, argv=0xbfffdf84) at apt-cache.cc:1802

So it looks like the iterator used to get translated descriptions causes
this.

This gets triggered by the following configuration:
% cat /etc/apt/apt.conf.d/20notranslation
Acquire::Languages "none";


** Summary changed:

- "apt-cache search" is slow because of listing /var/lib/apt/lists 45227 times
+ "apt-cache search" is slow because of listing /var/lib/apt/lists 45227 times (triggered by 'Acquire::Languages "none";')

-- 
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/1004947

Title:
  "apt-cache search" is slow because of listing /var/lib/apt/lists 45227
  times (triggered by 'Acquire::Languages "none";')

Status in “apt” package in Ubuntu:
  New
Status in “apt” package in Debian:
  New

Bug description:
  I've recognized that "apt-cache search" has become quite slow on my
  system, and when stracing it it shows that it lists the contents of
  /var/lib/apt/lists a lot (45227 times!):

      openat(AT_FDCWD, "/var/lib/apt/lists/", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
      getdents64(3, /* 156 entries */, 32768) = 13920
      getdents64(3, /* 0 entries */, 32768)   = 0
      close(3)                                = 0

  % grep -c 'openat(AT_FDCWD, "/var/lib/apt/lists/"' apt-cache-search-strace.txt
  45227
  (this count is reproducible with a second run)

  % time apt-cache search tomahawk
  apt-cache search tomahawk  3.84s user 4.54s system 99% cpu 8.427 total

  I am attaching the full output of strace.

  TEST CASE:
  % strace apt-cache search tomahawk 2>&1 | grep -c 'openat(AT_FDCWD, "/var/lib/apt/lists/"'
  45227

  
  ProblemType: Bug
  DistroRelease: Ubuntu 12.04
  Package: apt 0.8.16~exp12ubuntu10
  ProcVersionSignature: Ubuntu 3.2.0-24.39-generic-pae 3.2.16
  Uname: Linux 3.2.0-24-generic-pae i686
  ApportVersion: 2.0.1-0ubuntu8
  Architecture: i386
  Date: Sat May 26 19:39:11 2012
  EcryptfsInUse: Yes
  InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110427.1)
  SourcePackage: apt
  UpgradeStatus: Upgraded to precise on 2011-12-16 (162 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1004947/+subscriptions




More information about the foundations-bugs mailing list