Bug 281575 - Eclipse hangs in SourceMapper while doing java proposals
Summary: Eclipse hangs in SourceMapper while doing java proposals
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 3.5.2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2009-06-25 16:26 EDT by Kelly Campbell CLA
Modified: 2010-05-27 17:37 EDT (History)
5 users (show)

See Also:
daniel_megert: pmc_approved+
frederic_fusier: review+


Attachments
Proposed patch to fix the issue (1.77 KB, patch)
2009-06-26 10:53 EDT, Kelly Campbell CLA
no flags Details | Diff
Slightly better proposed patch (2.14 KB, patch)
2009-07-23 15:06 EDT, Kelly Campbell CLA
no flags Details | Diff
Proposed patch (2.50 KB, patch)
2009-09-25 12:29 EDT, Kelly Campbell CLA
Olivier_Thomann: iplog+
Details | Diff
Proposed fix (12.18 KB, patch)
2009-09-30 14:36 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (906 bytes, patch)
2009-09-30 14:47 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (12.18 KB, patch)
2009-09-30 14:54 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix for 3.5 maintenance (12.55 KB, patch)
2009-09-30 15:16 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kelly Campbell CLA 2009-06-25 16:26:32 EDT
Build ID: 3.4.2 M20090211-1700

Steps To Reproduce:
1. Setup a project which has large binary and source jars in the build path.
2. Try to get java proposals
3. Sometimes it's very slow or hangs


More information:
We have this stack trace during one of these hanging operations:
"main" prio=10 tid=0x080c5c00 nid=0x4a2e runnable [0xffd35000..0xffd38298]
   java.lang.Thread.State: RUNNABLE
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:114)
    at java.util.zip.ZipFile.<init>(ZipFile.java:131)
    at org.eclipse.jdt.internal.core.JavaModelManager.getZipFile(JavaModelManager.java:2203)
    at org.eclipse.jdt.internal.core.SourceMapper.findSource(SourceMapper.java:912)
    at org.eclipse.jdt.internal.core.SourceMapper.getSourceForRootPath(SourceMapper.java:891)
    at org.eclipse.jdt.internal.core.SourceMapper.findSource(SourceMapper.java:864)
    at org.eclipse.jdt.internal.core.SourceMapper.findSource(SourceMapper.java:834)
    at org.eclipse.jdt.internal.core.BinaryMethod.getParameterNames(BinaryMethod.java:165)
    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.getStyledDisplayString(LazyJavaCompletionProposal.java:224)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.handleSetData(CompletionProposalPopup.java:824)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$24(CompletionProposalPopup.java:814)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.handleEvent(CompletionProposalPopup.java:580)


I have a proposed patch which I will attach.
Comment 1 Olivier Thomann CLA 2009-06-26 10:42:57 EDT
Please attach your patch.
I don't see a deadlock.
Jay, please investigate.
Comment 2 Kelly Campbell CLA 2009-06-26 10:53:25 EDT
Created attachment 140240 [details]
Proposed patch to fix the issue

Sorry, thought I had attached it when I did the original report.

It doesn't deadlock, but if you have big jar files on non-local disk (or even sometimes local), it pauses for long enough to seem like a hang, several minutes in some cases.

I haven't been able to confirm with our users who reported the issue that this patch completely fixes the symptoms, but it shouldn't make it any worse.
Comment 3 Olivier Thomann CLA 2009-06-26 11:02:51 EDT
Patch looks interesting.
Would be good to get feedbacks on improvement using this patch.
Comment 4 Kelly Campbell CLA 2009-07-13 16:12:11 EDT
Feedback from our users who have been using the patch is positive. They say it doesn't hang for 20+ seconds like it did before, but still has slight pauses which are still annoying so it is an improvement.
Comment 5 Kelly Campbell CLA 2009-07-23 15:06:33 EDT
Created attachment 142439 [details]
Slightly better proposed patch

There's an earlier call to getSourceForRootPath() I should have wrapped with the zip file cache too. Updated patch attached.
Comment 6 Jay Arthanareeswaran CLA 2009-08-20 06:24:48 EDT
I definitely see some improvement with this patch, at least in one scenario. When the source jar is attached to the project as a library (along with the binary)  (and not as source attachment), we end up opening the same zip file more than once in the same thread. Inside the SourceMapper alone, the zip file is opened twice. The patch gets rid of one of them. In fact, there are other parties that are doing this in the same thread as well.

I will spend some more time investigating and see if we can move this caching call further outside in the invoking methods.
Comment 7 Jay Arthanareeswaran CLA 2009-08-31 07:13:31 EDT
With my performance test, I see about 4% performance improvement in terms of elapsed process time. This was done with binary and source files each of size about 50MB. While this is a reasonable performance improvement, I do not know if it can make such a bottleneck without this change.

Kelly, can you tell me what is the size of the jar/zip files you tested this with?
Comment 8 Jay Arthanareeswaran CLA 2009-09-08 03:10:26 EDT
Olivier,

The test FullSourceWorkspaceModelTests#testGetSourceBigJarNoAttachment() recorded a 4% improvement in terms of elapsed process time. And I am fine with the changes. Do you think the performance improvement is good enough to allow the patch?
Comment 9 Kelly Campbell CLA 2009-09-24 15:49:35 EDT
The jar size we were testing with was about 300MB. It was causing pauses of approx 20 seconds which are now < 1 sec with the patch.
Comment 10 Olivier Thomann CLA 2009-09-24 16:17:02 EDT
The numbers talk by themselves. Going from 20s down to less than 1s is a significant improvement.
+1 for the patch.

Jay, please also provide a patch for 3.5 maintenance. I think the improvement deserves a backport to 3.5.2. Make sure that iplog flag is set once the patch is released.

Daniel, ok for backporting ?
Comment 11 Dani Megert CLA 2009-09-25 04:01:19 EDT
The patch is fine except for the missing update of the copyright notice. Kelly, please add your credentials to the copyright notice in the following form:
name <e-mail> - bugzilla summary - bugzilla URL
e.g.
Dani Megert <dani@eclipse.org> - this is a bug - https://bugs.eclipse.org...

+1 for 3.5.2.
Comment 12 Kelly Campbell CLA 2009-09-25 12:29:18 EDT
Created attachment 148141 [details]
Proposed patch

Added copyright info to the patch.
Comment 13 Jay Arthanareeswaran CLA 2009-09-29 05:59:34 EDT
The patch provided with comment #12 goes fine with 3.5 as well.
Comment 14 Olivier Thomann CLA 2009-09-29 12:15:23 EDT
Released for 3.6M3.
Code check is required for verification.
Comment 15 Olivier Thomann CLA 2009-09-29 12:18:20 EDT
Released for 3.5.2.
Thanks for the patch, Kelly.
Comment 16 Frederic Fusier CLA 2009-09-30 06:09:33 EDT
Improve performances is a good thing but pass existing test is mandatory before saying that a patch is OK!

I got 75 failures while running all JDT/Core tests while doing the 3.5.2 build input today!!! There were all in search tests JavaSearchTests and JavaSearchBugsTests...

I haven't time to investigate why these tests are failing as I want to make the build input before the maintenance build is launched...

So, I revert the change and reopen the bug. Jay, please investigate the reason of these failures.
Comment 17 Frederic Fusier CLA 2009-09-30 06:13:35 EDT
I get the same failures in HEAD!
Comment 18 Frederic Fusier CLA 2009-09-30 06:18:56 EDT
Patch reverted in HEAD stream, hence remove the iplog flag on this bug...
Comment 19 Dani Megert CLA 2009-09-30 07:05:44 EDT
It's also breaks some of the org.eclipse.jdt.ui.tests.refactoring.all.AllAllRefactoringTests.
Comment 20 Olivier Thomann CLA 2009-09-30 09:14:41 EDT
Sorry guys. I did run the tests in the past. I'll investigate.
Comment 21 Olivier Thomann CLA 2009-09-30 14:36:44 EDT
Created attachment 148460 [details]
Proposed fix

All existing search tests passed.
Comment 22 Olivier Thomann CLA 2009-09-30 14:38:17 EDT
Frédéric, please review.
Comment 23 Olivier Thomann CLA 2009-09-30 14:41:25 EDT
Released for 3.6M3.
Verification is still required for 3.5.2 inclusion.

Kelly, please double-check that the performance is still improved with what is released in HEAD. Thanks.
Comment 24 Olivier Thomann CLA 2009-09-30 14:47:09 EDT
Created attachment 148461 [details]
Proposed fix

Forgot to include the latest change in the copyright.
Comment 25 Olivier Thomann CLA 2009-09-30 14:54:41 EDT
Created attachment 148462 [details]
Proposed fix

Hopefully this patch looks good.
Comment 26 Olivier Thomann CLA 2009-09-30 15:16:24 EDT
Created attachment 148465 [details]
Proposed fix for 3.5 maintenance

Here is a patch that applies directly on 3.5 maintenance. This replaces the last patch that was for HEAD.
Frédéric, please review this patch.
Comment 27 Frederic Fusier CLA 2009-10-01 05:08:39 EDT
Olivier,

The patch looks really good. Just a question about the iplog flag, as the patch comes from you, I doubt we can consider it as an external contribution.

I do not want to hide Kelly's initial effort but I think I remember that to be considered as an external contribution a patch should not be modified at all before being released. It's just for a legal matter... otherwise I'm personally completely OK to let this flag on :-)
Comment 28 Olivier Thomann CLA 2009-10-01 08:53:52 EDT
OK, I'll discuss with John about the iplog flag.
Comment 29 Olivier Thomann CLA 2009-10-01 10:05:03 EDT
Released for 3.5.2.
Code check is required for verification.

I keep the iplog set as the contribution is part of the patch.
Comment 30 Jay Arthanareeswaran CLA 2009-10-27 02:17:17 EDT
Verified for 3.6M3 by code inspection.
Comment 31 Jay Arthanareeswaran CLA 2010-01-21 01:21:38 EST
Verified for 3.5.2 RC2 by code inspection.
Comment 32 Srikanth Sankaran CLA 2010-01-21 01:50:34 EST
Verified.