@@ -303,7 +303,7 @@ class SerialBackgroundWorkQueue {
303303 std::mutex mutex;
304304
305305public:
306- bool stopAllWork = false ;
306+ std::atomic_bool stopAllWork = false ;
307307 void queueWork (std::function<void ()> work) {
308308 mutex.lock ();
309309 if (running && queue.empty ()) {
@@ -343,21 +343,24 @@ static SerialBackgroundWorkQueue pageInQueue;
343343// This code forces the page-ins on multiple threads so
344344// the process is not stalled waiting on disk buffer i/o.
345345void multiThreadedPageInBackground (DeferredFiles &deferred) {
346- using namespace std ::chrono;
347346 static const size_t pageSize = Process::getPageSizeEstimate ();
348347 static const size_t largeArchive = 10 * 1024 * 1024 ;
348+ #ifndef NDEBUG
349+ using namespace std ::chrono;
349350 static std::atomic_uint64_t totalBytes = 0 ;
350351 std::atomic_int numDeferedFilesAdvised = 0 ;
351352 auto t0 = high_resolution_clock::now ();
353+ #endif
352354
353355 auto preloadDeferredFile = [&](const DeferredFile &deferredFile) {
354356 const StringRef &buff = deferredFile.buffer .getBuffer ();
355357 if (buff.size () > largeArchive)
356358 return ;
357359
360+ #ifndef NDEBUG
358361 totalBytes += buff.size ();
359362 numDeferedFilesAdvised += 1 ;
360-
363+ # endif
361364#if _WIN32
362365 // Reference all file's mmap'd pages to load them into memory.
363366 for (const char *page = buff.data (), *end = page + buff.size ();
@@ -373,6 +376,7 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
373376#undef DEBUG_TYPE
374377#endif
375378 };
379+
376380 { // Create scope for waiting for the taskGroup
377381 std::atomic_size_t index = 0 ;
378382 llvm::parallel::TaskGroup taskGroup;
@@ -387,11 +391,13 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
387391 });
388392 }
389393
394+ #ifndef NDEBUG
390395 auto dt = high_resolution_clock::now () - t0;
391396 if (Process::GetEnv (" LLD_MULTI_THREAD_PAGE" ))
392397 llvm::dbgs () << " multiThreadedPageIn " << totalBytes << " /"
393398 << numDeferedFilesAdvised << " /" << deferred.size () << " /"
394399 << duration_cast<milliseconds>(dt).count () / 1000 . << " \n " ;
400+ #endif
395401}
396402
397403static void multiThreadedPageIn (const DeferredFiles &deferred) {
0 commit comments