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

Improve project initialization #2252

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

gayanper
Copy link
Contributor

Today when importing projects we disable auto build and reset it back to previous value to avoid conflicts between project imports and build jobs. But resetting back auto build to true cause the whole workspace to build again which takes considerable time for large projects which blocks all other operations.

The improvement use workspace scheduling rule to make sure another job cannot be executed at the same time such as a auto build according to how eclipse workspace sensitive jobs are implemented internally.

Must further future improvement would be to apply this rule at each project import iteration if further optimization is needed.

@gayanper
Copy link
Contributor Author

gayanper commented Sep 28, 2022

@jdneo @rgrunber Please check this and let me know. I was not really sure why the auto build was toggled in the first place, But i assume it might be because of conflicting jobs such as auto build, indexing etc.

@gayanper
Copy link
Contributor Author

Fix for #2192

@jdneo
Copy link
Contributor

jdneo commented Sep 29, 2022

Thank you @gayanper, I'll try the change later.

Meanwhile, I have a question: the current job is already wrapped as a WorkspaceJob and at line 278, we've set the job rule as the workspace root. Do we need to wrap it with another beginRule & endRule?

@gayanper
Copy link
Contributor Author

gayanper commented Sep 29, 2022

@jdneo If we check the code at org.eclipse.core.internal.resources.Workspace.prepareOperation seems like the org.eclipse.core.internal.resources.InternalWorkspaceJob.run pass null, which means the autobuild might not be interrupted. And the documentation of org.eclipse.core.resources.WorkspaceJob also mentions something similar to what I have found in the Notes section.

@rgrunber do you know anything different than what I have found above ?

@gayanper
Copy link
Contributor Author

@jdneo I missed the line 278, seems like it should set the rule for the whole job, But still I think we have the issue of stoping the build job if it was triggered before the import start. I need to validate if the current fix handles that.

@testforstephen
Copy link
Contributor

testforstephen commented Sep 29, 2022

Regarding the autobuild job, I see two drawbacks: one is slowing down the project import performance, another is conflict with maven commands running in the terminal. So I'm thinking if we can set the autobuild flag to false by default. And defer the build job to the run/debug phase.

@gayanper
Copy link
Contributor Author

Regarding the autobuild job, I see two drawbacks: one is slowing down the project import performance, another is conflict with maven commands running in the terminal. So I'm thinking if we can set the autobuild flag to false by default. And defer the build job to the run/debug phase.

Thats sounds like how IJ works. I guess then we delay the build to the point where we try to run/debug. Thats fine as well based on the workflow.

But on the other hand, I’m not sure if some syntax errors will go away if auto build is disabled. I have not used eclipse without autobuild for a long time.

@testforstephen
Copy link
Contributor

When auto build is disabled, jdt.ls still reports compilation errors for the opened files (workingcopy). This is because it uses a separate validation job to report diagnostics for these active files and doesn't depend on the auto build.

@gayanper
Copy link
Contributor Author

So you mean if i rename a method in a file and then open the file which has a reference for that method it should show me a compilation error in jdt.ls is it ? The rename is just changing the name not rename refactoring

@snjeza
Copy link
Contributor

snjeza commented Sep 29, 2022

A related issue - #2256

@gayanper
Copy link
Contributor Author

When auto build is disabled, jdt.ls still reports compilation errors for the opened files (workingcopy). This is because it uses a separate validation job to report diagnostics for these active files and doesn't depend on the auto build.

I think this is a good idea as well, If we all are ok with it I can try that out too. For mean time I have update the PR by adding support to interrupt the build manager before start the project import since while project import workspace job is running the build job will not kick in. Also the interruption implementation has a fallback if Eclipse core changes the internal implementation of IWorkspace.

@testforstephen
Copy link
Contributor

So you mean if i rename a method in a file and then open the file which has a reference for that method it should show me a compilation error in jdt.ls is it ? The rename is just changing the name not rename refactoring

Yes, if you rename a method in file A without refactoring. Then open file B, which has a reference to that old method, jdt.ls will report undefined method error even if autobuild is disabled.

@snjeza
Copy link
Contributor

snjeza commented Oct 1, 2022

@gayanper Which project and OS you are using?

@gayanper
Copy link
Contributor Author

gayanper commented Oct 2, 2022

@gayanper Which project and OS you are using?

I found this issue on Windows working with a project which has around 1k source files. But I don't have access to that machine nor the project anymore.

@snjeza
Copy link
Contributor

snjeza commented Oct 2, 2022

I found this issue on Windows working with a project which has around 1k source files. But I don't have access to that machine nor the project anymore.

@gayanper This issue is caused by redhat-developer/vscode-java#793
You can try https://github.com/spring-projects/spring-boot using VS Code 1.11.0 and pre-release.

@jdneo
Copy link
Contributor

jdneo commented Oct 8, 2022

The idea looks good. interrupting the build job should be better than toggling the auto build state.

Regarding to the performance, I tried it with redhat-developer/vscode-java#880 on Windows, but did not observe a significant improvement. Looks like the impact of resetting back auto build to true cause the whole workspace to build again is very limited.

@gayanper
Copy link
Contributor Author

gayanper commented Oct 8, 2022

Looks like the impact of resetting back auto build to true cause the whole workspace to build again is very limited.

Do you mean the changes done in this PR or the other linked PR @jdneo ?

@snjeza
Copy link
Contributor

snjeza commented Oct 8, 2022

Regarding to the performance, I tried it with redhat-developer/vscode-java#880 on Windows, but did not observe a significant improvement.

@jdneo could you check redhat-developer/vscode-java#793 ? See Steps For Reproduce.

@jdneo
Copy link
Contributor

jdneo commented Oct 8, 2022

Sorry I didn't say it clearly.

Do you mean the changes done in this PR or the other linked PR @jdneo ?

I mean the change in this PR.

@snjeza Changes in redhat-developer/vscode-java#880 are fine.

@gayanper
Copy link
Contributor Author

gayanper commented Oct 9, 2022

@jdneo yes may be with the other fix the impact is lower now of switching build state. But do you think the fix is not better than simply toggling the build mode when importing projects ?

@jdneo
Copy link
Contributor

jdneo commented Oct 9, 2022

I think interrupting is better than toggling.

I was just trying to share my observation in case that this is not related with my environment. :)

@gayanper
Copy link
Contributor Author

gayanper commented Oct 9, 2022

@jdneo thanks for clarifying. I will try to resolve the conflict soon

Today when importing projects we disable auto build and reset it back to
previous value to avoid conflicts between project imports and build jobs.
But resetting back auto build to true cause the whole workspace to build
again which takes considerable time for large projects which blocks all
other operations.

The improvement use workspace scheduling rule to make sure another job
cannot be executed at the same time such as a auto build according to
how eclipse workspace sensitive jobs are implemented internally and
try to interrupt the auto build before starting project import.

Fix tests
- removing unnecessary stubs reported by mockito
- add wait for project import
Copy link
Contributor

@jdneo jdneo left a comment

Choose a reason for hiding this comment

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

Though the performance improvement is not that significant, but I can still observe that after applying this interruption mechanism, less jobs can be observed when opening a Gradle project which has already imported beforehand:

Below is the outputs of the build status terminal after opening a project.

Before
52ebba19 Importing Gradle project(s) [Done]
64fceaa2 Synchronizing projects [Done]
eedb8d0d Synchronizing projects [Done]
a35904c2 Building [Done]
d207e4d3 Building [Done]
a7eafa7d Building [Done]
After
b7b590bb Importing Gradle project(s) [Done]
8b198365 Synchronizing projects [Done]
3d196bdb Synchronizing projects [Done]

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

Successfully merging this pull request may close these issues.

4 participants