[lld] [lld][MachO] Follow-up to use madvise() for threaded file page-in. (PR #157917)
John Holdsworth via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 11 00:08:25 PDT 2025
================
@@ -334,29 +338,37 @@ class SerialBackgroundQueue {
// This code forces the page-ins on multiple threads so
// the process is not stalled waiting on disk buffer i/o.
void multiThreadedPageInBackground(DeferredFiles &deferred) {
+ using namespace std::chrono;
static const size_t pageSize = Process::getPageSizeEstimate();
static const size_t largeArchive = 10 * 1024 * 1024;
-#ifndef NDEBUG
- using namespace std::chrono;
- std::atomic_int numDeferedFilesTouched = 0;
static std::atomic_uint64_t totalBytes = 0;
+ std::atomic_int numDeferedFilesAdvised = 0;
auto t0 = high_resolution_clock::now();
-#endif
auto preloadDeferredFile = [&](const DeferredFile &deferredFile) {
const StringRef &buff = deferredFile.buffer.getBuffer();
if (buff.size() > largeArchive)
return;
-#ifndef NDEBUG
+ if (((uintptr_t)buff.data() & (pageSize - 1)))
+ return; // Not mmap()'d (not page aligned).
----------------
johnno1962 wrote:
I saw that but it's not clear how to do this as by the time buffers having been opened in InputFile.cpp arrive in Driver.cpp they are MemoryBufferRefs which don't have this method. mmap()'d file buffers are guaranteed to be page aligned I would have thought but some other buffers might also be aligned by chance. This doesn't seem to matter though I can't say it is proven.
https://github.com/llvm/llvm-project/pull/157917
More information about the llvm-commits
mailing list