Bug 374955 - [syntax highlighting] "Highlight enclosing brackets" still has performance problems
Summary: [syntax highlighting] "Highlight enclosing brackets" still has performance pr...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M7   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2012-03-21 13:31 EDT by Markus Keller CLA
Modified: 2012-03-29 11:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2012-03-21 13:31:07 EDT
I20120320-1400

"Highlight enclosing brackets" still has performance problems:

- in StyledText, put the caret to the beginning of the last method declaration
- press and hold Shift+ArrowDown

=> selection updating is very sluggish
Comment 1 Deepak Azad CLA 2012-03-21 14:07:56 EDT
(In reply to comment #0)
> I20120320-1400
> 
> "Highlight enclosing brackets" still has performance problems:
> 
> - in StyledText, put the caret to the beginning of the last method declaration
> - press and hold Shift+ArrowDown
> 
> => selection updating is very sluggish

With
Version: 4.2.0
Build id: I20120315-1300

I do not observe a 'significant' difference in performance with and without the feature. I am not saying there is no difference, just that the difference is not significant, and calling selection updating 'very sluggish' may be a bit harsh :-)

In any case, the problem does deserve another look.
Comment 2 Markus Keller CLA 2012-03-21 15:40:36 EDT
When I hold Shift+ArrowDown in StyledText in my main workspace, I see the caret moving but the selection only follows up sporadically. In CleanUpTest, it's even worse.

In the runtime workbench, it's not as bad, but it's still slower than with enclosing brackets disabled.


YourKit says that in my main workspace, almost half of the time is spent in org.eclipse.egit.ui.internal.actions.RepositoryAction.selectionChanged(IAction, ISelection), and the rest is in our
org.eclipse.jface.text.source.DefaultCharacterPairMatcher.findEnclosingPeers(..)

=> performance is still not good enough, but on our fast machines, it is acceptable unless something else also eats CPU cycles.


A problem is that StyledText and TextViewer fire selection events for each selection change, but when the caret moves, there's only a post selection event from TextViewer.
Comment 3 Deepak Azad CLA 2012-03-29 07:09:37 EDT
(In reply to comment #2)
> YourKit says that in my main workspace, almost half of the time is spent in
> org.eclipse.egit.ui.internal.actions.RepositoryAction.selectionChanged(IAction,
> ISelection), and the rest is in our
I was not able to reproduce this. Markus, you had mentioned on chat that you will open a bug against EGit with more information. Did you already do that?
Comment 4 Markus Keller CLA 2012-03-29 10:40:46 EDT
(In reply to comment #3)
The other performance hog I saw was in org.eclipse.egit.ui.internal.actions.AddToIndexActionHandler#isEnabled()

To reproduce, you need to:
- have a workspace with many closed projects
- enable the "Git" action set (via Customize Perspective... dialog) and show the Git actions in the toolbar

Then, for each text selection change event, RepositoryActionHandler#
getProjectsInRepositoryOfSelectedResources(IStructuredSelection) loops over all projects in the workspace and tries to find their repository provider, which takes a lot of time due to bug 375634.

Once that bug is fixed, there's no relevant additional slowdown any more.
Comment 5 Markus Keller CLA 2012-03-29 11:16:44 EDT
I did some more measurements and I didn't find anything more to optimize. Discussed with Dani and we decided that the current solution is good enough, also given that the enclosing brackets option is not enabled by default.

If this turns out to be a problem in practice, we might have to move the updating into a post selection listener if we didn't find matching brackets after a screenfull of characters. Closing for now.