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

Defer initialization of classpath to the background if called from UI #1525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Dec 17, 2024

Currently there are some bad behaving UI components in the eclipse IDE that trigger resolving of the classpath containers in the UI, this leads to very bad startup performance and even deadlocks in startup.

This now detects the issue, logs a warning of the offending component and defer the initialization of classpath to a background job, this currently increase time from starting eclipse until UI is shown noticeable.

Fix #1481

@vogella
Copy link
Contributor

vogella commented Dec 17, 2024

I'm very happy to see that you working on the startup performance of Eclipse @laeubi Thank you.

Copy link

github-actions bot commented Dec 17, 2024

Test Results

  275 files   -    10    275 suites   - 10   39m 27s ⏱️ - 11m 21s
3 586 tests ±    0  3 508 ✅  -     2   76 💤 ± 0  1 ❌ +1  1 🔥 +1 
8 086 runs   - 2 864  7 907 ✅  - 2 812  177 💤  - 54  1 ❌ +1  1 🔥 +1 

For more details on these failures and errors, see this check.

Results for commit 588fad8. ± Comparison against base commit 5baaa6d.

♻️ This comment has been updated with latest results.

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Christoph for working on this issue, I'm very happy about that as well.
But the presented solution does seem to be very robust and I don't think pde.core should handle issues that arise from wrong usage in the UI. Therefore I would prefer a solution in the UI classes where this is caused. E.g. the editor should defer the initialization to a background thread. I would like to have this only as a last resort solution.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 18, 2024

But the presented solution does seem to be very robust and I don't think pde.core should handle issues that arise from wrong usage in the UI.

It is not nice but reflects reality in Eclipse IDE runtime environment and we can quite easy remove it once a better solution is there. Also there are sadly numerous places (and maybe some unknown places) where this happens and at least we get a warning in the log now when new things arise.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 18, 2024

Interestingly the warning even triggers in the CI build already :-D

https://ci.eclipse.org/pde/job/eclipse.pde/job/PR-1525/2/maven-warnings/new/source.b23f7a3a-eedd-4a60-b012-8767a6761747/#6521

@jukzi
Copy link
Contributor

jukzi commented Dec 18, 2024

Thanks for working on the issue. But i think one should not make decisions based on thread name. Better solve it in the caller.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 18, 2024

Thanks for working on the issue. But i think one should not make decisions based on thread name. Better solve it in the caller.

Will you propose PR to do so for JDT?

And as mentioned before the worst that can happen is it will work as before, so there is no real "danger" in this decision.

@jukzi
Copy link
Contributor

jukzi commented Dec 18, 2024

Will you propose PR to do so for JDT?

no, but that is no reason to introduce dirty hacks.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 18, 2024

Will you propose PR to do so for JDT?

no, but that is no reason to introduce dirty hacks.

This is not a dirty "hack" it is a workaround for the situation that is is very unlikely that changes will occur any time soon in an unrelated project (JDT) as it is "understaffed" (as every other project as well... So if we can improve the situation quite easy and make it better for all users of PDE there is no reason to wait for something that maybe never happens.

And even if it does, we can easily remove the code again without any problem.

@vogella
Copy link
Contributor

vogella commented Dec 18, 2024

I agree that we should apply this PR.

PDE should protect itself from bad callers which seems to be in this case JDT.

@iloveeclipse
Copy link
Member

I agree that we should apply this PR.
PDE should protect itself from bad callers which seems to be in this case JDT.

I'm not sure you understand possible implications of that PR. JDT will see classpath containers that are not fully initialized or use containers that can't be initialized at all. This may lead to unpredictable plugin compilation results.

Please check org.eclipse.jdt.core.ClasspathContainerInitializer.initialize(IPath, IJavaProject) javadoc and org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(IJavaProject, IPath) code.

I agree with @jukzi this is a dirty hack and dangerous one too.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 18, 2024

I'm not sure you understand possible implications of that PR. JDT will see classpath containers that are not fully initialized or use containers that can't be initialized at all. This may lead to unpredictable plugin compilation results.

When the computation is done, we notify JDT that something has changed and then it will simply reevaluate. Also as compilation does not happen in the UI thread for this case nothing changes at all, this all calling from the UI is as far as I can see only to inspect the classpath entries and the init of the container is just a side-effect.

Also as you mention the javadoc it says:

Binds a classpath container to a IClasspathContainer for a given project,
or silently fails if unable to do so.

So it would be even valid to do nothing and simply return, I just wanted to be a little bit nice here ;-)

I would be happy to not require this so I suggest anyone who feels uncomfortable with this put a breakpoint in

org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(IJavaProject, IPath)

and fix all call sites that enter her in the main (== UI thread) when you start an eclipse, sadly those are very deep nested so its not trivial, and obviously those are not compile threads in any case.

@laeubi
Copy link
Contributor Author

laeubi commented Dec 27, 2024

I now have made some more tests:

  1. Simply return when called from UI Thread --> The Plugin Container is not added (as expected) unless one changes something from the Manifest or something else so PDE set it again
  2. Current solution I see the container is set due to the Job I started (like if someone changes the manifest or similar)
  3. Throw an exception, then I see
eclipse.buildId=unknown
java.version=21
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=de_DE
Framework arguments:  -product org.eclipse.sdk.ide

org.eclipse.jdt.core
Error
Fri Dec 27 14:15:20 CET 2024
Exception while initializing all containers

org.eclipse.core.runtime.CoreException: Called from Ui thread!
   at org.eclipse.pde.internal.core.RequiredPluginsInitializer.initialize(RequiredPluginsInitializer.java:81)
   at org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:3209)
   at org.eclipse.jdt.internal.core.JavaModelManager$11.run(JavaModelManager.java:3097)
   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2457)
   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2482)
   at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:3155)
   at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2131)
   at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:3970)
   at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3127)
   at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3291)
   at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:2405)
   at org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject.java:488)
   at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:246)
   at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:508)
   at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:228)
   at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:569)
   at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:292)
   at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:278)
   at org.eclipse.jdt.internal.core.PackageFragmentRoot.getKind(PackageFragmentRoot.java:539)
   at org.eclipse.jdt.internal.core.PackageFragment.getKind(PackageFragment.java:367)
   at org.eclipse.jdt.internal.core.PackageFragment.validateExistence(PackageFragment.java:596)
   at org.eclipse.jdt.internal.core.Openable.exists(Openable.java:212)
   at org.eclipse.jdt.internal.core.PackageFragment.exists(PackageFragment.java:189)
   at org.eclipse.jdt.ui.StandardJavaElementContentProvider.exists(StandardJavaElementContentProvider.java:509)
   at org.eclipse.jdt.ui.StandardJavaElementContentProvider.getParent(StandardJavaElementContentProvider.java:246)
   at org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider.getParent(JavaNavigatorContentProvider.java:118)
   at org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider.getParent(SafeDelegateTreeContentProvider.java:105)
   at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider$4.run(NavigatorContentServiceContentProvider.java:646)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
   at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.findParents(NavigatorContentServiceContentProvider.java:623)
   at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.findPaths(NavigatorContentServiceContentProvider.java:594)
   at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.findPaths(NavigatorContentServiceContentProvider.java:603)
   at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.getParents(NavigatorContentServiceContentProvider.java:330)
   at org.eclipse.jface.viewers.AbstractTreeViewer.getParentElement(AbstractTreeViewer.java:1793)
   at org.eclipse.jface.viewers.TreeViewer.getParentElement(TreeViewer.java:573)
   at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpand(AbstractTreeViewer.java:1733)
   at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2737)
   at org.eclipse.ui.navigator.CommonViewer.setSelectionToWidget(CommonViewer.java:439)
   at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1706)
   at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:3253)
   at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1662)
   at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:1091)
   at org.eclipse.ui.navigator.CommonViewer.setSelection(CommonViewer.java:369)
   at org.eclipse.ui.navigator.CommonNavigator.selectReveal(CommonNavigator.java:385)
   at org.eclipse.ui.internal.navigator.actions.LinkEditorAction$2$1.run(LinkEditorAction.java:104)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
   at org.eclipse.ui.internal.navigator.actions.LinkEditorAction$2.runInUIThread(LinkEditorAction.java:93)
   at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:148)
   at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
   at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
   at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5042)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4522)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
   at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
   at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:663)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:570)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:178)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
   at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
   at java.base/java.lang.reflect.Method.invoke(Method.java:580)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1454)

but the container is there because at UI startup the init of container is triggered automatically.

So an alternative could be to simply throw an exception...

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now have made some more tests:

1. Simply return when called from UI Thread --> The Plugin Container is not added (as expected) unless one changes something from the Manifest or something else so PDE set it again

2. Current solution I see the container is set due to the Job I started (like if someone changes the manifest or similar)

3. Throw an exception, then I see

I still think this should be solved in JDT, i.e. the Java Editor should defer the initialization if called from the UI thread. Since it's a UI component it can also test if the main thread is really the UI thread. I'm really not inclined to workaround bad behavior of other UI parts in the core of PDE.
Concurrency in the intialization of JDT is already a problem and introducing more of it probably doesn't make it better. One also has to consider headless apps that just run in the main thread. They will also be affected of this change.

Therefore I want to ask the JDT committers again to help here as they know JDT better and propose a solution for JDT UI.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 6, 2025

I have now added a check that uses dynamic import package + reflection to check if it is called from the (SWT) UI thread, so there is no need to check for the thread name anymore.

I'll wait if the JDT issue(s) are solved until next week (13.01.2025) and then plan to merge this to unblock PDE, the IDE and its users from UI blocking during startup phase.

jukzi
jukzi previously requested changes Jan 6, 2025
Copy link
Contributor

@jukzi jukzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirty hack

@laeubi
Copy link
Contributor Author

laeubi commented Jan 6, 2025

dirty hack

Please either abstain from reviews or leave actionable comments, this is not a hack but common practice to use reflection if direct calls are not possible or not wanted (due to coupling). Dynamic Import Package is also a standard OSGi technology for late binding of optional imports.

@laeubi laeubi requested review from jukzi and HannesWell January 6, 2025 13:41
@jukzi
Copy link
Contributor

jukzi commented Jan 6, 2025

leave actionable comments,

the only legit action is to close this PR as there is no legit way to fix it in pde. any descision made here based on the caller or calling thread is just too bad.

@laeubi laeubi dismissed jukzi’s stale review January 6, 2025 13:52

Not interested in providing reasonable review.

@laeubi laeubi requested review from vogella and removed request for jukzi January 6, 2025 13:53
@laeubi laeubi changed the title Defer initialization of classpath to the background if called from main Defer initialization of classpath to the background if called from UI Jan 6, 2025
Copy link
Contributor

@vogella vogella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review was requested. It is hard to decide what to do here for me. @laeubi maybe send an email to the JDT dev list so that the team can decide if they can fix it. If not, I would suggest to bring it to the PMC to discuss.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 6, 2025

@vogella I added you as reviewer as you are left a comment that one can interpret as a positive review but you haven't given explicit review here yet. So if you don't care (anymore) feel free to remove you from the list of reviewers again.

Beside that @HannesWell has already expressed positive feedback here but (valid) concerns where expressed about how to check for an UI thread. This is now addressed with a check that is done hundred of times in our platform code (but because we do not want direct UI binding in an optional non intrusive way).

Still @HannesWell and me agree that fixing it "at the root" would be preferable of course, but now after 4 weeks I don't see much hope of any progress here and the current situation is simply unacceptable as it potentially blocking the IDE startup when one has package-explorer/java editor in an IDE (what we can assume as a very common use-case here).

And as PDE and JDT are distinct project there is nothing from any PMC perspective PDE can do to "force" movement in JDT, so having a "grace-period" of just another week seems fair to me instead of waiting an undefined amount of time for "something" to happen. If this changes any time we can easily remove the workaround at any time, because there is no API involved or any behavior change that would influence valid callers so there is really no need to worry even tough we all would wish a better alternative.

@vogella
Copy link
Contributor

vogella commented Jan 6, 2025

I'm still interested and I also still share the same opinion (PDE should protect itself from bad callers which seems to be in this case JDT.).

@HannesWell is PL in PDE so he can make the cut-off decision if two committers (you and @jukzi) disagree. If someone disagrees with this decision he can escalate this to the PMC.

@HannesWell
Copy link
Member

Still @HannesWell and me agree that fixing it "at the root" would be preferable of course, but now after 4 weeks I don't see much hope of any progress here and the current situation is simply unacceptable as it potentially blocking the IDE startup when one has package-explorer/java editor in an IDE (what we can assume as a very common use-case here).

Thank you for the update. I think the code is less 'dangerous' now, but yes I'm still strongly favor of fixing this at the root in JDT. I consider this as a really last resort solution. Async work can already be a problem now and introducing more (even just for special cases) can potentially cause more problems.

Therefore I can just repeat myself and ask the JDT committer that are active in this discussion to help here so that we don't have to decide if it's better to not fix the problem to to apply this change.
I can also try to have a look into this, but I'm actually busy with other things at the moment. So this might take longer than the desired week.

I'm still interested and I also still share the same opinion (PDE should protect itself from bad callers which seems to be in this case JDT.).

I wouldn't sign this statement in general. While it's nice to protect callers from bad behavior it's practically not feasible because it would blow up a lot of code-parts if done everywhere. And what's right and what's wrong might also depend on the exact case (although I cannot tell if there is a reasonable use-case for calling the code discussed from the UI thread, but who knows...).
Eventually it's the responsibility of the caller to call the code in the 'correct' way. And in very general, calling this from the UI thread is not semantically wrong. It 'just' has the potential to give a bad user-experience due to a long blocked UI.

@HannesWell is PL in PDE so he can make the cut-off decision if two committers (you and @jukzi) disagree. If someone disagrees with this decision he can escalate this to the PMC.

We can also have a vote on this among all PDE committers.

@gireeshpunathil
Copy link
Contributor

I support this PR. justification: in the absence of a better alternative, a working solution to the stated problem (deadlock) with no known side effects in the common code path is reasonable. people with concerns on (real / imaginary) side effects are best placed to refine the code base through future PRs.

Currently there are some bad behaving UI components in the eclipse IDE
that trigger resolving of the classpath containers in the process of
creating the UI, this leads to very bad startup performance and even
deadlocks in startup.

This now detects the issue, logs a warning of the offending component
and defer the initialization of classpath to a background job, this
currently decrease time from starting eclipse until UI is shown
noticeable.

Fix eclipse-pde#1481
@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

I don't think a vote would be the right thing to do as this change does not affect PDE project as a whole. A simple PL decision by @HannesWell and @vik-chand would be enough.

Regarding the concern about "async" operation, a classpath container can change any time and it does for example if you edit the manifest, so this is really nothing to worry about and just usual usage.

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

In case we are voting: +1 from me for this change (assuming JDT cannot / doesn't want to fix their code)

@jukzi
Copy link
Contributor

jukzi commented Jan 7, 2025

The whole eclipse plugin concept was designed such that an RCP app could be render a skeleton before any plugin code is executed. The plugin.xml was choosen to be a text file such that it was not needed to run any java code while already knowing which ui parts they would contribute. Somewhen that good initial idea was violated and the plugin code was executed before the workbench is shown. I do not know when or why it started but my best guess is that it is the e4.compatibility.CompatibilityEditor which got it wrong. So while it may be possible to be fixed in JDT it would be even better to solve it e4 for all UI plugins somewhere here:

org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor(org.eclipse.ui.texteditor.AbstractTextEditor).init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) line: 3213	
	org.eclipse.ui.internal.EditorReference.initialize(org.eclipse.ui.IWorkbenchPart) line: 353	
	org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor(org.eclipse.ui.internal.e4.compatibility.CompatibilityPart).create() line: 344	

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

e4.compatibility.CompatibilityEditor is only a small wrapper to call the inherited methods in the 3x based editors.

@jukzi
Copy link
Contributor

jukzi commented Jan 7, 2025

e4 calls it a feature not a bug:
https://wiki.eclipse.org/Eclipse4/RCP/FAQ#Lazy_Instantiantion

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

e4 calls it a feature not a bug: https://wiki.eclipse.org/Eclipse4/RCP/FAQ#Lazy_Instantiantion

Sounds like you are mixing stuff here. The lazy instantiation feature applies to editors and views which are currently not visible / selected in a stack. So if you have 300 Java editors open in the editor area not all are intialized at startup but only the active one. This was also the case in the 3.x time and is one of the reason which the startup time of Eclipse is not linear dependent of the number of editors / views open.

@iloveeclipse
Copy link
Member

agree that fixing it "at the root" would be preferable of course, but now after 4 weeks I don't see much hope of any progress here

Well, we had lot of vacations in this time. Now we see some signs of life in JDT:
eclipse-jdt/eclipse.jdt.core#3468 (comment)

So assuming the offending call would be removed

https://github.com/eclipse-jdt/eclipse.jdt.core/blob/17fc31849b5225c441e93a8cc7eec636cd05067f/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java#L616

we would not need this PR.

@laeubi : would you please push a PR to JDT core with this line removed, and assuming we would not have any JDT test fails, we can try to merge this for M1 and see which possible side effects in PDE/m2e/Xtext will arise.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

Even without this call there is still one issue left in jdt ui:

Would still makes sense to push the PR to JDT core I think. Are you planning to push it or shall someone else do it? I'm surprised that @jarthana did not push a PR as he already had the change in his workspace.

@iloveeclipse
Copy link
Member

Even without this call there is still one issue left in jdt ui:

also platform has a pending issue:

So what? This shouldn't be an excuse to add workarounds in PDE? Let fix the problems where they are rooted, not add workarounds here and there at all possible JDT / Platform clients.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

Would still makes sense to push the PR to JDT core I think. Are you planning to push it or shall someone else do it? I'm surprised that @jarthana did not push a PR as he already had the change in his workspace.

but I'm not very confident I should push such changes forward, because beside from deleting the offending line I can't in any way answer question or decide what consequences this has. So actually a JDT committer would be much better person to "own" such change... anyways I have created a PR here:

@vogella
Copy link
Contributor

vogella commented Jan 7, 2025

So actually a JDT committer would be much better person to "own" such change... anyways I have created a PR here:

I also had the same impression and was surprised that neither @jarthana nor another JDT committer actively discussing this issue here created the PR

@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

So what?

You claimed

So assuming the offending call would be removed
...
we would not need this PR.

what is simply wrong, because it will still be required unless someone

fix the problems where they are rooted

because otherwise the problem will simply persist and this has some serious consequences as it possibly deadlocks the whole IDE startup (as complained by @jukzi).

Because of that I do not want to "wait" for too much things just to see we missed the M1 / whatever / ... and need to wait another release for that. If we are fast, the code can simply be removed without any effort, so we do not miss anything (beside not let people complain about hanging Eclipse).

@iloveeclipse
Copy link
Member

The problem is not a new one and is not observable by many people (otherwise we will see more bugs reported), so I do not see urgent need to apply the proposed workaround. Also if is a new problem, we've missed yet another component that must be fixed because the code in question is pretty old.

With that, I agree with @jukzi and I do not see a value to add a questionable workaround in PDE (which will remain forever) if we can consistently work on improving things that cause the problem in the platform/JDT.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

Just search for "eclipse freezes on startup splash screen" and you will see that this is far from being "not observable by many people"... I don't want to state that it is exactly this problem, but the people see such problems and are annoyed, and the usual "workaround" is to kill the process and try again (and being annoyed)...

if we can consistently work on improving things that cause the problem in the platform/JDT.

Well the first reaction on JDT was "can you fix it yourself" so I'm not very confident that it is "consistently work" on ... but the blame will be put on PDE.

@jukzi
Copy link
Contributor

jukzi commented Jan 7, 2025

There are two issues:

  1. The deadlock during startup is a real show stopper once it happens
  2. The slow opening of the Java Editor is a bad performance but is tolerable.
    I am very thankfull @laeubi tries to work on both. Both seem to be consequences of other dirty workarounds in the past gone wrong. instead of piling up more workarounds it would be better to fix the issues at the root.
    The deadlock could either be cleanly worked around by a) not using Jobs framework this early or b) that the Job framework is fixed in the means that .join() will not lead to deadlock when Jobmanager is suspendend. c) do not suspend JobManager during startup.
    To me c) sounds most clean. While it may have been a performance improvements 21 years ago it should not be a performance problem these days to have some concurrent threads during startup. And even if - the deadlock is much more serious then performance. So i suggest to try c) first.

@laeubi
Copy link
Contributor Author

laeubi commented Jan 7, 2025

a) not using Jobs framework this early

The problem is that the called method can't decide "how early" it is called and in the usual case (UI is showing) one actually want a job, so one is back to the problem to how detect/decide that (what is this PR about)

that the Job framework is fixed in the means that .join() will not lead to deadlock when Jobmanager is suspendend

The join do not do any deadlock, it simply returns and that is documented, the problem is that the Job itself never executes and the code needs to wait for the result. In this particular case it needs to contact an updatesite to get the available IUs, without this information it could not proceed --> wait for ever (so it is not a real deadlock)

do not suspend JobManager during startup

In any case it will lead to bad performance, it will just be maybe very slow (but not wait forever)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDT calls PDE Classpath on startup with open Editor hindering the UI to show up
6 participants