Bug 237241 - Content assist does not scale with javadoc on type with many members
Summary: Content assist does not scale with javadoc on type with many members
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 263156 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-06-16 05:01 EDT by Benno Baumgartner CLA
Modified: 2009-03-10 09:30 EDT (History)
5 users (show)

See Also:


Attachments
Profiler data (4.69 KB, application/zip)
2008-06-16 09:57 EDT, Dani Megert CLA
no flags Details
First proposal (29.22 KB, patch)
2008-06-26 06:48 EDT, David Audel CLA
no flags Details | Diff
Proposed fix (35.07 KB, patch)
2009-03-05 08:25 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2008-06-16 05:01:12 EDT
I20080613-2000

Given JOGL OpenGL SWT snipped from here http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet209.java?view=co
1. Paste to new project
2. Add SWT to the Build path
3. Add JOGL to the BP (https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=9260&expandFolder=9260&folderID=0)
4. On line 99 type 'gl.gl', ctrl-space, 'C'
Is: very fast, good
5. Add Javadoc for JOGL to jogl library (https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=9260&expandFolder=9260&folderID=0)
6. On line 99 type 'gl.gl', ctrl-space, 'C'
Is:
 Once the content assist popup is up, Eclipse is not responding for about 40 (sic!) seconds, on every keystroke, and to make it worse: the popup shell stays on top of every other application window.
Should:
 Maybe it's acceptable the first time, but subsequents calls must be fast

This is major, if not critical, I had to remove Javadoc, which makes it very difficult to program against this library.

'GL' is a C wrapper class containing around 4700 members. Yes, this is a lot but might happen in such an setup, plus JOGL is a quite common used library.

This is also in 3.3.2

Not sure if this is JDT/Texts or JDT/Cores fault:

"main" prio=6 tid=0x00038d20 nid=0x1690 runnable [0x0007e000..0x0007fc3c]
        at java.lang.String.indexOf(String.java:1597)
        at java.lang.String.indexOf(String.java:1564)
        at java.lang.String.indexOf(String.java:1546)
        at org.eclipse.jdt.internal.core.BinaryMethod.extractJavadoc(BinaryMethod.java:625)
        at org.eclipse.jdt.internal.core.BinaryMethod.getParameterNames(BinaryMethod.java:252)
        at org.eclipse.jdt.internal.codeassist.InternalCompletionProposal.findMethodParameterNames(InternalCompletionProposal.java:120)
        at org.eclipse.jdt.core.CompletionProposal.findParameterNames(CompletionProposal.java:1950)
        at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.appendUnboundedParameterList(CompletionProposalLabelProvider.java:106)
        at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createMethodProposalLabel(CompletionProposalLabelProvider.java:265)
        at org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider.createStyledLabel(CompletionProposalLabelProvider.java:536)
        at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.computeDisplayString(LazyJavaCompletionProposal.java:245)
        at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getDisplayString(LazyJavaCompletionProposal.java:230)
        at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.isValidPrefix(AbstractJavaCompletionProposal.java:709)
        at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.isValidPrefix(LazyJavaCompletionProposal.java:349)
        at org.eclipse.jdt.internal.ui.text.java.JavaMethodCompletionProposal.isValidPrefix(JavaMethodCompletionProposal.java:236)
        at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.validate(AbstractJavaCompletionProposal.java:672)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeFilteredProposals(CompletionProposalPopup.java:1455)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$4(CompletionProposalPopup.java:1418)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:369)

I can send you the project in question if you want to, I'm not sure if I'm allowed to attach it here.
Comment 1 Dani Megert CLA 2008-06-16 09:53:18 EDT
Can reproduce using 3.4 RC4. Not a regression (same since at least 3.2).

NOTE: On platforms where no virtual table is available, we already see the blocked UI on first code assist because the labels need to be computed for all elements in the table. On the reported platform (WindowsXP) the virtual table is available and hence only when filtering the first time we need to compute all the labels.


The time is spent in BinaryMethod.extractJavadoc(IType, String) and there in code where String.indexOf(String, int) is called (esp. line 625).

Possible fix could be to run once through the javadoc string which is cached and store the start positions.
Comment 2 Dani Megert CLA 2008-06-16 09:57:07 EDT
Created attachment 105028 [details]
Profiler data
Comment 3 Dani Megert CLA 2008-06-16 10:29:41 EDT
I could probably add a workaround for the virtual table case but there's nothing I can do for the non-virtual table case as I do need all the labels.

Some background data: the proposal list contains 4731 proposals/entries.
Comment 4 David Audel CLA 2008-06-26 06:48:20 EDT
Created attachment 105876 [details]
First proposal

With this patch the ranges of all children of the declaring type are computed at the same time to avoid to call 'indexOf' from the start of the javadoc for each methods and fields.

The test case of comment 0 take 2 seconds instead of 40 seconds.

This patch is only a draft and can be slightly improved.
Comment 5 Jerome Lanneluc CLA 2008-06-26 07:35:56 EDT
Changing target milestone to 3.5 since:
- this is not a regression (comparing to at least 3.2)
- the change is simple (risk of introducing a regression in a maintenance release)
- even if much better, the performance is still not acceptable (2s is too long for code assist)
Comment 6 David Audel CLA 2009-02-03 11:06:11 EST
*** Bug 263156 has been marked as a duplicate of this bug. ***
Comment 7 David Audel CLA 2009-03-05 08:25:43 EST
Created attachment 127647 [details]
Proposed fix

When extracting the javadoc of an element the range of this javadoc is stored to be reused later and the positions of all the previous html anchor are stored.
These positions will be used to extract the javadoc of the other elements.
This data are stored inside the 'javadocCache' of 'PerProjectInfo'.

With this patch the test case of comment 0 take between 1 and 2 seconds instead of 35 seconds.
It is not perfect but it is better than 35 seconds.
Comment 8 David Audel CLA 2009-03-05 08:30:39 EST
Released for 3.5M6.
Comment 9 Olivier Thomann CLA 2009-03-10 09:30:09 EDT
Verified for 3.5M6 using I20090310-0100.