make File system synchronization less annoying (IDEA-246854)
authorPeter Gromov <peter@jetbrains.com>
Thu, 13 Aug 2020 11:00:36 +0000 (13:00 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 13 Aug 2020 11:18:04 +0000 (11:18 +0000)
show it after a longer delay, log VFS events causing it

GitOrigin-RevId: 540dd08e5e26af9cd850da389b78b147b54ac344

platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshSessionImpl.java

index 5ecf7305787e8d5f3c487c0add128e51df1682e6..7dd564e0afdf7b79d479643b5878f996f76922bf 100644 (file)
@@ -10,6 +10,8 @@ import com.intellij.openapi.application.TransactionGuard;
 import com.intellij.openapi.application.WriteAction;
 import com.intellij.openapi.application.impl.ApplicationImpl;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.progress.util.ProgressWindow;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.AsyncFileListener;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -193,7 +195,17 @@ final class RefreshSessionImpl extends RefreshSession {
         WriteAction.run(() -> {
           app.runWriteActionWithNonCancellableProgressInDispatchThread(IdeBundle.message("progress.title.file.system.synchronization"), null, null, indicator -> {
             indicator.setText(IdeBundle.message("progress.text.processing.detected.file.changes", events.size()));
+            int progressThresholdMillis = 5_000;
+            ((ProgressWindow) indicator).setDelayInMillis(progressThresholdMillis);
+            long start = System.currentTimeMillis();
+
             fireEventsInWriteAction(events, appliers);
+
+            long elapsed = System.currentTimeMillis() - start;
+            if (elapsed > progressThresholdMillis) {
+              LOG.warn("Long VFS change processing (" + elapsed + "ms, " + events.size() + " events): " +
+                       StringUtil.trimLog(events.toString(), 10_000));
+            }
           });
         });
       }