Sluggish editor (some analysis and YourKit snapshot) 关注
So since IDEA 10 the editor has been sluggish on a decent spec machine (Core 2 Duo, 3GB-6GB RAM). This has become even worse in the 10.5 EAP and it is particularly bad over a Remote Desktop connection (which I suspect may be an oversealous redraw problem).
Since I installed YourKit the other day to diagnose another IDEA performance problem, I decided to profile the editor sluggishness. I've uploaded a snapshot here: http://dl.dropbox.com/u/361417/idea.exe-2011-05-03.snapshot.zip
The test was to start IDEA from fresh, load a project and a typical Java file in that project, wait for IDEA to idle and then start CPU profiling (with invocation counts). I then switched back to IDEA and held down the right arrow key to make the cursor move to the right, wrapping to the next line, etc. Without profiling, the cursor usually jumps about 4-5 characters at a time, with the CPU at about 80-100% of 1 core and the cursor continues moving for another 4-5 characters after I let go of the key. Under profiling, IDEA stops updating the cursor position after about 5 seconds of pressing the key and I can see the CPU pegged at 100% of one core with a spike up to ~70% of total CPU every 5 seconds or so. After I let go of the key, it takes about a minute for IDEA to get back to idle, while under profiling.
Looking at the snapshot, it would seem that CaretModelImpl.moveCaretRelatively is causing an incredible number of queries into the contents of the file. From 498 invocations of moveCaretRelatively, there are 4.2 million invocations of EditorUtil.calcSoftWrapUnawareOffset, which in turn results in 7.5 million invocations of EditorUtil.calcColumnNumber, which in turn results in 12 million invocations of CharBuffer.charAt.
This is all for moving the cursor, character by character, across 10 lines of about 50-100 characters each.
I would love to see an improvement in this area in the 10.5 release.
I created corresponding ticket at the tracker - IDEA-69153.
Please provide additional info there.