mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
start dumb mode more often
When number of updated files is small also count their size and start dumb mode if the size is large enough, currently 1M (configurable)
This commit is contained in:
@@ -105,10 +105,12 @@ import java.util.concurrent.Phaser;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -287,6 +289,20 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
}
|
||||
}
|
||||
|
||||
long getChangedFilesSize() {
|
||||
Set<VirtualFile> changed = new THashSet<>();
|
||||
AtomicLong changedFilesSize = new AtomicLong();
|
||||
|
||||
Consumer<VirtualFile> consumer = file -> {
|
||||
if (file.isValid() && changed.add(file)) {
|
||||
changedFilesSize.addAndGet(file.getLength());
|
||||
}
|
||||
};
|
||||
myChangedFilesCollector.myVfsEventsMerger.getChangedFiles().forEach(consumer);
|
||||
myChangedFilesCollector.myFilesToUpdate.values().forEach(consumer);
|
||||
return changedFilesSize.get();
|
||||
}
|
||||
|
||||
public static boolean isProjectOrWorkspaceFile(@NotNull VirtualFile file, @Nullable FileType fileType) {
|
||||
return ProjectCoreUtil.isProjectOrWorkspaceFile(file, fileType);
|
||||
}
|
||||
@@ -383,6 +399,7 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
ContentHashesSupport.initContentHashesEnumerator();
|
||||
contentHashesEnumeratorOk = true;
|
||||
}
|
||||
long started = System.currentTimeMillis();
|
||||
storage = new VfsAwareMapIndexStorage<>(
|
||||
IndexInfrastructure.getStorageFile(name),
|
||||
extension.getKeyDescriptor(),
|
||||
@@ -391,6 +408,7 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
extension.keyIsUniqueForIndexedFile(),
|
||||
extension.traceKeyHashToVirtualFileMapping()
|
||||
);
|
||||
LOG.info("Initialized index " + (System.currentTimeMillis() - started) + " for " + name);
|
||||
|
||||
final InputFilter inputFilter = extension.getInputFilter();
|
||||
final Set<FileType> addedTypes = new THashSet<>();
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
@@ -113,6 +114,9 @@ public class FileBasedIndexProjectHandler implements IndexableFileSet, Disposabl
|
||||
myIndex.removeIndexableSet(this);
|
||||
}
|
||||
|
||||
private static final int ourMinFilesToStartDumMode = Registry.intValue("ide.dumb.mode.minFilesToStart", 20);
|
||||
private static final int ourMinFilesSizeToStartDumMode = Registry.intValue("ide.dumb.mode.minFilesSizeToStart", 1048576);
|
||||
|
||||
@Nullable
|
||||
public static DumbModeTask createChangedFilesIndexingTask(final Project project) {
|
||||
final FileBasedIndex i = FileBasedIndex.getInstance();
|
||||
@@ -121,8 +125,8 @@ public class FileBasedIndexProjectHandler implements IndexableFileSet, Disposabl
|
||||
}
|
||||
|
||||
final FileBasedIndexImpl index = (FileBasedIndexImpl)i;
|
||||
if (index.getChangedFileCount() < 20) {
|
||||
return null;
|
||||
if (index.getChangedFileCount() < ourMinFilesToStartDumMode) {
|
||||
if (index.getChangedFilesSize() < ourMinFilesSizeToStartDumMode) return null;
|
||||
}
|
||||
|
||||
return new DumbModeTask(project.getComponent(FileBasedIndexProjectHandler.class)) {
|
||||
|
||||
@@ -191,6 +191,11 @@ editor.virtual.lines.description=Number of virtual empty lines displayed at the
|
||||
|
||||
ide.showIndexRebuildMessage=false
|
||||
|
||||
ide.dumb.mode.minFilesToStart=20
|
||||
ide.dumb.mode.minFilesToStart.description=How many files should be changed for IDE to start dumb mode
|
||||
ide.dumb.mode.minFilesSizeToStart=1048576
|
||||
ide.dumb.mode.minFilesSizeToStart.description=How large should be updated files's size to start dumb mode in case there are a few of them
|
||||
|
||||
ide.tabbedPane.bufferedPaint=true
|
||||
ide.tabbedPane.dragOutMultiplier=1.2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user