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:
https://raw.github.com/php/php-src/master/ext/date/lib/parse_date.c

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(ArrayList.java:177)
     at java.util.AbstractList$Itr.hasNext(AbstractList.java:339)
     at com.intellij.pom.tree.events.impl.TreeChangeImpl.addChangeAtOffset(TreeChangeImpl.java:126)
     at com.intellij.pom.tree.events.impl.TreeChangeImpl.addChangeInternal(TreeChangeImpl.java:119)
     at com.intellij.pom.tree.events.impl.TreeChangeImpl.addChange(TreeChangeImpl.java:104)
     at com.intellij.pom.tree.events.impl.TreeChangeEventImpl.processElementaryChange(TreeChangeEventImpl.java:147)
     at com.intellij.pom.tree.events.impl.TreeChangeEventImpl.addElementaryChange(TreeChangeEventImpl.java:114)
     at com.intellij.psi.impl.source.tree.CompositeElement.remove(CompositeElement.java:903)
     at com.intellij.psi.impl.source.tree.CompositeElement.access$400(CompositeElement.java:49)
     at com.intellij.psi.impl.source.tree.CompositeElement$5.makeChange(CompositeElement.java:752)
     at com.intellij.psi.impl.source.tree.ChangeUtil$2.runInner(ChangeUtil.java:190)
     at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:44)
     at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:131)
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(ChangeUtil.java:177)
     at com.intellij.psi.impl.source.tree.CompositeElement.replaceAllChildrenToChildrenOf(CompositeElement.java:740)
     at com.intellij.psi.impl.source.text.DiffLog$ReplaceElementWithEvents.doActualPsiChange(DiffLog.java:269)
     at com.intellij.psi.impl.source.text.DiffLog.performActualPsiChange(DiffLog.java:57)
     at com.intellij.psi.impl.DocumentCommitThread$7.runInner(DocumentCommitThread.java:710)
     at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:44)
     at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:131)
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.DocumentCommitThread.doActualPsiChange(DocumentCommitThread.java:707)
     at com.intellij.psi.impl.DocumentCommitThread$5$1$1.run(DocumentCommitThread.java:597)
     - locked <79358e5b0> (a com.intellij.psi.PsiLock)
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$8.compute(CodeStyleManagerImpl.java:749)
     at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:110)
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$10.compute(CodeStyleManagerImpl.java:784)
     at com.intellij.formatting.FormatterImpl.runWithFormattingDisabled(FormatterImpl.java:772)
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:780)
     at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:746)
     at com.intellij.psi.impl.DocumentCommitThread$5$1.run(DocumentCommitThread.java:593)
     at com.intellij.psi.impl.TextBlock.performAtomically(TextBlock.java:102)
     at com.intellij.psi.impl.DocumentCommitThread$5.process(DocumentCommitThread.java:590)
     at com.intellij.psi.impl.DocumentCommitThread$5.process(DocumentCommitThread.java:580)
     at com.intellij.psi.impl.PsiDocumentManagerImpl$5.run(PsiDocumentManagerImpl.java:374)
     at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1013)
     at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommit(PsiDocumentManagerImpl.java:362)
     at com.intellij.psi.impl.DocumentCommitThread$4.run(DocumentCommitThread.java:522)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
     at java.awt.EventQueue.access$400(EventQueue.java:82)
     at java.awt.EventQueue$2.run(EventQueue.java:676)
     at java.awt.EventQueue$2.run(EventQueue.java:674)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
     at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:700)
     at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:525)
     at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

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


Also seen in the timeline as the yellow region on the right:
awt-event-blocked.png

2 comments

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 (!!!).

0

Hi Robert,

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

Denis

0

Please sign in to leave a comment.