Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eclipse maven workspace is too slow with bnd plugin #3415

Closed
prafullp opened this issue Sep 10, 2019 · 17 comments
Closed

Eclipse maven workspace is too slow with bnd plugin #3415

prafullp opened this issue Sep 10, 2019 · 17 comments
Assignees
Labels
maint-candidate Issues or pull requests that are candidates for a maintenance release
Milestone

Comments

@prafullp
Copy link

I am using bnd 4.2.0 version

I am building OSGI based application and I am using Eclipse IDE for development. My project is maven based and I am using bnd maven plugins for creating bundles and I use bnd tools eclipse plugin to manage bndrun files in eclipse. Opening bndrun files in Eclipse and even building and debugging application is extremely slow.

I did some investigation in bnd plugin code and found that in class

DefaultRunProvider.java
line number 25, the Workspace object is never resolved as

project.hasNature(BndtoolsConstants.NATURE_ID)
is always false. So everytime a for example a bndrun file is opened, it creates a new Workspace Object. AS the code proceeds further, in

MavenImplicitProjectRunListener.java
MavenImplicitProjectRepository implicitRepo = workspace.getPlugin(MavenImplicitProjectRepository.class);

is found as null and because of that MavenImplicitProjectRepository is newly initialized and whole process of resolution is done every time. At the end of resolution the MavenImplicitProjectRepository object is added to plugin registry but after closing the bndrun file and opening it again, the whole information is lost and the same set of initializations happens again and again. This takes a lot of time in opening the bndrun file.

For a workspace with around 30 projects, it takes around 20-30 seconds to open the file.

The same behavior is observed when debugger is launched. It takes similar amount of time to get the debugger point to the file where debug point is set.

This behavior is only for visible when maven based project is configured. Its not observed if the project is bnd workspace.

The issue of slow opening of bndrun file can be replicated using following sample project https://github.com/prafullp/maven-bnd-issue.git

Need guidance if I have configured the project wrongly or something is missing.

@bjhargrave
Copy link
Member

@rotty3000 Can you look into this?

@gamerson
Copy link
Contributor

hey @prafullp I was not able to reproduce this with the latest Bndtools 4.3.0RC1 available here: https://bndtools.jfrog.io/bndtools/releasecandidate/

But all I did was clone your example repo, import the project and and then open the devenv.bndrun file. It opened quickly, or at least I perceived it as quick.

@prafullp
Copy link
Author

Hey @gamerson . Thanks for your quick response. The problem is visible more when you have more complicated set of projects. In order to make it visible I have downloaded YCSB project from github and added bnd.bndrun file in cassandra-binding project.

So if you re-import the workspace you would see the slowness. On my machine it took 43 seconds for the file to open. File opening is not the only problem that we have. Because of the same reason, the launch of application and debugging it is also too slow.

Please note that you will not be able to run this project as I didn't intend to do that. I am hoping if there are fixes, the same fix will lead to solution of all other problems.

I have not checked the behavior with 4.3 release candidate but I will check and let you know.

@prafullp
Copy link
Author

I also tried 4.3 release candidate and unfortunately it has not impact.

@rotty3000 rotty3000 self-assigned this Sep 11, 2019
@bjhargrave bjhargrave added this to the 4.4 milestone Sep 13, 2019
@rotty3000
Copy link
Contributor

I could not reproduce the issue with the 4.3.0 snapshot as you can see in this screen capture:

maven-bnd-issue

The laptop used is also quite small:
image

@prafullp
Copy link
Author

Hi @rotty3000 ,

Unfortunately I don't see this behavior on my machine. I still see slowness. I am testing on window 10 machine though. I tried it on Ubuntu on virtual box and I didn't see any improvements. Below is the recording captured by me for the same workspace

Below are the specs
Eclipse 2019-03
BND - 4.3.0.201909101255-SNAPSHOT
OS - Windows 10 Enterprise
Processor - Intel i7 1.9 GHz 4 Cores
RAM - 32 GB
Recording #1

Please let me know details on how and what to debug. I can provide you details which might be helpful.

@gamerson
Copy link
Contributor

gamerson commented Sep 18, 2019

hello @prafullp

In recent versions of Eclipse there is a UI responsiveness monitoring feature. You can enable it, and Eclipse will automatically take dumps for you to show who is hogging the UI thread. (see screenshots)

Here is the preference page
Screen Shot 2019-09-18 at 12 06 38 PM

And UI Freezes will be show in the error log (Window > Show View > Other > Error Log)

Screen Shot 2019-09-18 at 12 06 18 PM

If this is not available for you in the Error log, you can take your own thread dumps. When you see the slowness (while the editor is waiting to come up), can you take some thread dumps (try to take several) of the java process? It appears that some task is running on the main SWT/UI thread and it is doing some long work (accessing network perhaps or lots of IO?) and that is causing the slowness. Once we have the thread dumps we will know who is hogging the UI thread.

@prafullp
Copy link
Author

prafullp commented Sep 26, 2019

Hi @gamerson ,

Was bit busy, so couldn't revert back. I took some random thread dump samples and I have attached them here.
threadDump.zip

Below is the error log from Eclipse after enabling UI responsiveness monitoring
ui_freeze.log

The other thing I noticed is that today the time it took was only around 18 seconds to open the file. I will look into the details of what has changed since my last test.

@gamerson
Copy link
Contributor

Thanks @prafullp

These thread dumps show exactly where work is being done on the UI thread.
Two of the thread dumps show that when opening the BndEditor it is creating
implicit repos and then loading the mavenProject info for all of those
which can be slow and should ideally be done off the UI thread.

The stacktrace below is on the main thread (SWT thread)

org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager.readRepos(EnhancedLocalRepositoryManager.java:178)
        at
org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager.find(EnhancedLocalRepositoryManager.java:102)
        at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:315)
        at
org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:224)
        at
org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:338)
        at
org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:202)
        at
org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:212)
        at
org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:185)
        at
org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:116)
        at
org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:628)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.lambda$3(ProjectRegistryManager.java:808)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$$Lambda$647/903222219.call(Unknown
Source)
        at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
        at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
        at
org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.execute(ProjectRegistryManager.java:958)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.readProjectWithDependencies(ProjectRegistryManager.java:805)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.readProjectWithDependencies(ProjectRegistryManager.java:788)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$2.call(ProjectRegistryManager.java:1001)
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$2.call(ProjectRegistryManager.java:1)
....
        at
org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.getMavenProject(ProjectRegistryManager.java:999)
        at
org.eclipse.m2e.core.internal.project.registry.MavenProjectFacade.getMavenProject(MavenProjectFacade.java:242)
        at
bndtools.m2e.WorkspaceProjectPostProcessor.postProcessResult(WorkspaceProjectPostProcessor.java:36)
        at
aQute.bnd.maven.lib.resolve.DependencyResolver.discoverArtifacts(DependencyResolver.java:181)
        at
aQute.bnd.maven.lib.resolve.DependencyResolver.resolve(DependencyResolver.java:138)
        at
aQute.bnd.maven.lib.resolve.DependencyResolver.resolve(DependencyResolver.java:105)
        at
aQute.bnd.maven.lib.resolve.DependencyResolver.getFileSetRepository(DependencyResolver.java:150)
        at
aQute.bnd.maven.lib.resolve.BndrunContainer.getFileSetRepository(BndrunContainer.java:218)
        at
bndtools.m2e.MavenImplicitProjectRepository.createRepo(MavenImplicitProjectRepository.java:199)
        at
bndtools.m2e.MavenImplicitProjectRepository.<init>(MavenImplicitProjectRepository.java:71)
        at
bndtools.m2e.MavenImplicitProjectRunListener.create(MavenImplicitProjectRunListener.java:48)
        at bndtools.launch.util.LaunchUtils.createRun(LaunchUtils.java:87)
        at bndtools.editor.BndEditor.loadEditModel(BndEditor.java:592)
        at bndtools.editor.BndEditor.init(BndEditor.java:540)
        at
org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:365)
        at
org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:345)

@rotty3000
Copy link
Contributor

rotty3000 commented Sep 26, 2019

I'm testing a small change to offload the initialization of the implicit repo from the UI thread.

Ideally I'll send a PR and ask that you build bndtools and install the result to verify because I couldn't reproduce the UI blocking to the degree that was encountered.

@rotty3000
Copy link
Contributor

@prafullp can you try to build the fix and give feedback.

@rotty3000
Copy link
Contributor

@prafullp I've merged this so shortly you should be able to try the snapshot available here: https://bndtools.jfrog.io/bndtools/update

@prafullp
Copy link
Author

prafullp commented Oct 2, 2019

Hi @rotty3000 ,
I tried out the latest build from 01st October and I didn't see any improvement. Please find attached ui freeze logs.
ui_freeze.log

Below is the bnd version installed.

Bndtools https://bndtools.org/ bndtools.core 4.4.0.DEV-201910011729-gc6821c1 bndtools.main.feature

@rotty3000
Copy link
Contributor

rotty3000 commented Oct 2, 2019

So a colleague of mine noted that your ui_freeze.log lines don't match up with those at 4.4.0.DEV-201910011729-gc6821c1 (gc6821c1 being the git sha where that snapshot was built).

Could you follow these steps:

  • completely uninstall bndtools/bndtools.m2e via Help > About Eclipse IDE > Installation Details >
  • open the ${eclipse.install}/plugins and remove all biz.aQute.*, bndtools.* and org.bndtools.*
  • install bndtools from this update site https://bndtools.jfrog.io/bndtools/update

@bjhargrave
Copy link
Member

Could you follow these steps:

I would suggest you make a new, fresh Eclipse installation and install Bndtools into that.

@prafullp
Copy link
Author

prafullp commented Oct 8, 2019

Hi @rotty3000 , @bjhargrave

I downloaded eclipse 2019-09. I couldn't see the stacktrace that I used to see but the time it takes to open the file is still 17 seconds. Please find below latest logs and screenshots

ui_freeze2.log

Capture

Bndtools https://bndtools.org/ bndtools.core 4.4.0.DEV-201910071628-g94c8da7 bndtools.main.feature

@gamerson
Copy link
Contributor

hey @prafullp I don't see any UI thread in your latest ui_freeze. So it seems something else is causing the hang.

@bjhargrave bjhargrave added the maint-candidate Issues or pull requests that are candidates for a maintenance release label Oct 18, 2019
rotty3000 added a commit to rotty3000/bnd that referenced this issue Oct 18, 2019
…ners

fixes bndtools#3415

Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
bjhargrave pushed a commit that referenced this issue Oct 18, 2019
fixes #3415

Signed-off-by: Raymond Augé <raymond.auge@liferay.com>

Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
bjhargrave pushed a commit that referenced this issue Oct 18, 2019
…ners

fixes #3415

Signed-off-by: Raymond Augé <raymond.auge@liferay.com>

Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maint-candidate Issues or pull requests that are candidates for a maintenance release
Projects
None yet
Development

No branches or pull requests

4 participants