[PATCH] D48397: [dsymutil] Force mmap'ing of binaries

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 15:28:37 PDT 2018


JDevlieghere created this revision.
JDevlieghere added a reviewer: friss.

After the recent refactoring that introduced parallel handling of different object, the binary holder became unique per object file. This defeats its optimization of caching archives, leading to an archive being opened for every binary it contains. This is obviously unfortunate and will need to be refactored soon.

Luckily in practice, the impact of this is limited as most files are mmap'ed instead of memcopy'd. There's a caveat however: when the memory buffer requires a null terminator and it's a multiple of the page size, we allocate instead of mmap'ing. If this happens for a static archive, we end up with N copies of it in memory, where N is the number of objects in the archive, leading to exuberant memory usage.  This provided a stopgap solution to ensure that all the files it loads are mmap in memory by removing the requirement for a terminating null byte.


Repository:
  rL LLVM

https://reviews.llvm.org/D48397

Files:
  llvm/tools/dsymutil/BinaryHolder.cpp


Index: llvm/tools/dsymutil/BinaryHolder.cpp
===================================================================
--- llvm/tools/dsymutil/BinaryHolder.cpp
+++ llvm/tools/dsymutil/BinaryHolder.cpp
@@ -62,7 +62,7 @@
   // (either because the archive is not there anymore, or because the
   // archive doesn't contain the requested member), this will still
   // provide a sensible error message.
-  auto ErrOrFile = MemoryBuffer::getFileOrSTDIN(Filename);
+  auto ErrOrFile = MemoryBuffer::getFileOrSTDIN(Filename, -1, false);
   if (auto Err = ErrOrFile.getError())
     return Err;
 
@@ -136,7 +136,7 @@
     StringRef Filename, sys::TimePoint<std::chrono::seconds> Timestamp) {
   StringRef ArchiveFilename = Filename.substr(0, Filename.find('('));
 
-  auto ErrOrBuff = MemoryBuffer::getFileOrSTDIN(ArchiveFilename);
+  auto ErrOrBuff = MemoryBuffer::getFileOrSTDIN(ArchiveFilename, -1, false);
   if (auto Err = ErrOrBuff.getError())
     return Err;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48397.152180.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/68892cc2/attachment.bin>


More information about the llvm-commits mailing list