preload classes info

GitOrigin-RevId: 2662e1310fb805811635476b097ef1bc26afa608
This commit is contained in:
Egor Ushakov
2019-09-26 13:06:20 +00:00
committed by intellij-monorepo-bot
parent ed037f6922
commit 8be73ff432
2 changed files with 52 additions and 1 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @author Eugene Zhuravlev
@@ -12,9 +12,12 @@ import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.jdi.VirtualMachineProxy;
import com.intellij.debugger.impl.DebuggerUtilsImpl;
import com.intellij.debugger.impl.PrioritizedTask;
import com.intellij.debugger.impl.attach.SAJDWPRemoteConnection;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.ThreeState;
@@ -713,6 +716,10 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
}
//myAllThreadsDirty = true;
myTimeStamp++;
if (Registry.is("debugger.types.preload")) {
scheduleTypesDataPreload();
}
}
@Override
@@ -777,4 +784,47 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
protected abstract boolean calcValue();
}
private long myLastTypesCheckTime;
private int myLastTypesSize;
// Preload all supertypes information for faster queries (especially for emulated method breakpoints)
private void scheduleTypesDataPreload() {
if (DebuggerUtilsImpl.isRemote(myDebugProcess)) {
return;
}
DebuggerManagerThreadImpl.assertIsManagerThread();
long time = System.currentTimeMillis();
if (time > myLastTypesCheckTime + 10000) {
List<ReferenceType> types = allClasses();
if (time > myLastTypesCheckTime + 60000 || Math.abs(types.size() - myLastTypesSize) > 1000) {
scheduleTypesDataPreload(types.iterator());
myLastTypesCheckTime = time;
myLastTypesSize = types.size();
}
}
}
private void scheduleTypesDataPreload(Iterator<ReferenceType> iterator) {
if (iterator.hasNext()) {
myDebugProcess.getManagerThread().schedule(PrioritizedTask.Priority.LOWEST, () -> {
long start = System.currentTimeMillis();
do {
ReferenceType type = iterator.next();
if (type.isPrepared()) {
try {
DebuggerUtilsImpl.supertypes(type);
}
catch (ObjectCollectedException ignored) {
}
}
if (System.currentTimeMillis() - start > 50) { // batch process for 50ms
// schedule here to allow other LOWEST priority commands to be processed
scheduleTypesDataPreload(iterator);
return;
}
}
while (iterator.hasNext());
});
}
}
}
@@ -387,6 +387,7 @@ debugger.call.tracing=false
debugger.call.tracing.arguments=true
debugger.renderers.annotations=true
debugger.smart.step.inplace=true
debugger.types.preload=true
execution.java.always.debug=false
execution.java.always.debug.description=Always run java processes with the debug agent