The best way to make Idea/IntelliJ IDE more "snappy"

Greetings, all !

I've started using Idea 12 CE, and have found the overall experience quite good.

The only thing that I have rubbed against is that sometimes (when typing quickly), the UI will lag while it performs lookups for autocompletion (or background compiling, or something...). By my estimation, I have noticed this delay reach up to 500ms, but it is usually <250ms.

It's worth noting that this is on a quad core 3ghz Xeon workstation, with loads of RAM & HD space, and no other applications exhibit such behaviour (which is to say, it's not my machine, which is an OS X machine).

Nonetheless, if the intermittant lag had stayed so low (100-500ms), then I probably would have just dealt with it... never composing this forum post, as it is not sufficiently annoying (nor time-consuming) to warrant discarding the whole tool along with its most excellent features.

Today, however... O BROTHER!!!

As an experiment, I thought that I might use Idea's multi-column editing & autocompletion to accelerate the conversion... or... attempted conversion of a C source file to JAVA, and for the first step, I created a new java class and pasted the source code into the new file.

The UI instantly locked up for many minutes (not an exageration). I gave it some time, and had thought that it had truly frozen (never to recover), but when I came back to that virtual screen later (maybe 30 minutes later). IDEA had recovered, and was doing fine.

I thought this was odd, but since I was happy to continue with the experiment, I started editing the file. As far as I can tell, at the very first opportunity that IDEA was trying to present a popup menu of autocompletion choices, the UI locked up again (this time about 5 minutes).

This seems really odd to me, but also like a great opportunity to help IntelliJ to become faster & more responsive. Consequently, easier to use.

Now, I would presume that there would be no purposeful compiling/process-waiting/blocking or other heavy-lifting in the UI thread... as IMO, there is no reason that the UI thread should have to block and wait for anything, as it's purpose is to interface with *me* :) However, when performing a thread dump of IDEA when it is in this state, it looks like it *IS* deep in some java parsing (or something).

If it helps, the file I pasted into the editor is here:

I would be greatly interested to know if anyone else can reproduce this issue (is it VM-specific?), and if there is interest in fixing it from someone who is already more knowledgable of IDEA's innards. I would presume that this is the same lag that I usually see (only in a more sever form).

Copied here is what I consider to be the relevant thread (taking one core to 100% utilization):

"AWT-EventQueue-1 12.1.4#IC-129.713, eap:false [WriteAccessToken]" prio=6 tid=105152000 nid=0x13866c000 runnable [13866a000]
   java.lang.Thread.State: RUNNABLE
     at java.util.ArrayList.size(
     at java.util.AbstractList$Itr.hasNext(
     at com.intellij.psi.impl.source.tree.CompositeElement.remove(
     at com.intellij.psi.impl.source.tree.CompositeElement.access$400(
     at com.intellij.psi.impl.source.tree.CompositeElement$5.makeChange(
     at com.intellij.psi.impl.source.tree.ChangeUtil$2.runInner(
     at com.intellij.pom.core.impl.PomModelImpl.runTransaction(
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(
     at com.intellij.psi.impl.source.tree.CompositeElement.replaceAllChildrenToChildrenOf(
     at com.intellij.psi.impl.source.text.DiffLog$ReplaceElementWithEvents.doActualPsiChange(
     at com.intellij.psi.impl.source.text.DiffLog.performActualPsiChange(
     at com.intellij.psi.impl.DocumentCommitThread$7.runInner(
     at com.intellij.pom.core.impl.PomModelImpl.runTransaction(
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.DocumentCommitThread.doActualPsiChange(
     at com.intellij.psi.impl.DocumentCommitThread$5$1$
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$8.compute(
     at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$10.compute(
     at com.intellij.formatting.FormatterImpl.runWithFormattingDisabled(
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(
     at com.intellij.psi.impl.DocumentCommitThread$5$
     at com.intellij.psi.impl.TextBlock.performAtomically(
     at com.intellij.psi.impl.DocumentCommitThread$5.process(
     at com.intellij.psi.impl.DocumentCommitThread$5.process(
     at com.intellij.psi.impl.PsiDocumentManagerImpl$
     at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(
     at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommit(
     at com.intellij.psi.impl.DocumentCommitThread$
     at java.awt.event.InvocationEvent.dispatch(
     at java.awt.EventQueue.dispatchEventImpl(
     at java.awt.EventQueue.access$400(
     at java.awt.EventQueue$
     at java.awt.EventQueue$
     at Method)
     at java.awt.EventQueue.dispatchEvent(
     at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(
     at com.intellij.ide.IdeEventQueue._dispatchEvent(
     at com.intellij.ide.IdeEventQueue.dispatchEvent(
     at java.awt.EventDispatchThread.pumpOneEventForFilters(
     at java.awt.EventDispatchThread.pumpEventsForFilter(
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(
     at java.awt.EventDispatchThread.pumpEvents(
     at java.awt.EventDispatchThread.pumpEvents(

   Locked ownable synchronizers:
     - <792f357f0> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)

Also seen in the timeline as the yellow region on the right:

Comment actions Permalink

In retrospect, I realize that the condition cleared (again) while I was typing the forum post... the timeline area of interest is actually the *GREEN* area (!!!).

Comment actions Permalink

Hi Robert,

Could you make a cpu snapshot for the problem situation and provide it for further analysis?



Please sign in to leave a comment.