[PATCH] libdpkg: use mmap if available to parse package info files
Use mmap instead of slurping entire "Packages" or "available" files
into memory. This should reduce memory pressure on low-memory
machines.
Reported-by: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Bill Allombert wrote:
> Maybe this is because I reran autoreconf
> before compiling or because I do not use the same version of autoconf/automake
> as you.
Maybe some versions of autoconf include an implied AC_CHECK_FUNCS(mmap)
somehow.
> In any case, we certainly have mmap support, so it seems like a bug
> if it was not detected on your system.
Yes, agreed. Thanks for noticing.
It would be nice to get some benchmarks: how does this affect dpkg’s
speed and memory usage?
configure.ac | 4 ++--
debian/changelog | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6e8c6b9..68ed38a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,8 +124,8 @@ DPKG_CHECK_DECL([WCOREDUMP], [sys/wait.h])
DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \
strnlen strerror strsignal \
scandir alphasort unsetenv])
-AC_CHECK_FUNCS([strtoul isascii bcopy memcpy lchown setsid getdtablesize \
- posix_fadvise])
+AC_CHECK_FUNCS([strtoul isascii bcopy memcpy mmap lchown setsid \
+ getdtablesize posix_fadvise])
AC_DEFINE(LIBDPKG_VOLATILE_API, 1, [Acknowledge the volatility of the API.])
DPKG_COMPILER_WARNINGS
diff --git a/debian/changelog b/debian/changelog
index 16ddb25..8daeb9d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,11 @@ dpkg (1.15.8) UNRELEASED; urgency=low
- Add versioned Build-Depends.
* Fix variable usage after delete in dselect.
+ [ Jonathan Nieder ]
+ * Use mmap if present to read status and available memory-efficiently.
+ The code to do this was already present, but it was not being enabled
+ through the configure script. Thanks to Bill Allombert for the report.
+
[ Updated programs translations ]
* Russian (Yuri Kozlov). Closes: #579149
* Swedish (Peter Krefting).
--
1.7.1
Reply to: