Hi, Attached is an experimental patch to estimate the size of the DynamicMMap from the size of the Release files that the cache is generated from, instead of using a hardcoded estimate of 24MB.
I discarded my test builds (and accidentally the notes) about it when I expected DynamicMMap to be removed entirely. IIRC, the estimate is about double the size of the final cache; it should be the size of the uncompressed Packages files (23MB for Lenny, 25MB for Sid). Patch is for apt-0.7.18 Steve
Sat Nov 29 12:23:08 GMT 2008 Steve Cotton <st...@s.cotton.clara.co.uk> * 380509: set the size of the DynamicMMap based on the size of the package files This changes pkgMakeStatusCache, but not pkgMakeOnlyStatusCache. The latter is appears to only be called from debDpkgDB::ReadyPkgCache, which itself is exported, but only called in two test files scratch.cc and testextract.cc (searched Apt and Aptitude for others). diff -rN -u old-apt-0.7.18.steve.2/apt-pkg/pkgcachegen.cc new-apt-0.7.18.steve.2/apt-pkg/pkgcachegen.cc --- old-apt-0.7.18.steve.2/apt-pkg/pkgcachegen.cc 2008-11-29 12:40:25.000000000 +0000 +++ new-apt-0.7.18.steve.2/apt-pkg/pkgcachegen.cc 2008-11-29 12:40:25.000000000 +0000 @@ -793,8 +793,6 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, MMap **OutMap,bool AllowMem) { - unsigned long MapSize = _config->FindI("APT::Cache-Limit",24*1024*1024); - vector<pkgIndexFile *> Files; for (vector<metaIndex *>::const_iterator i = List.begin(); i != List.end(); @@ -836,7 +834,10 @@ } /* At this point we know we need to reconstruct the package cache, - begin. */ + begin by allocating an mmap'd file as large as the total of the + input files; all unused space will be truncated afterwards. */ + unsigned long DefaultMapSize = ComputeSize(Files.begin(),Files.end()); + unsigned long MapSize = _config->FindI("APT::Cache-Limit", DefaultMapSize); SPtr<FileFd> CacheF; SPtr<DynamicMMap> Map; if (Writeable == true && CacheFile.empty() == false)