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

Bad performance when working with non quarkus/MP projects #290

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

angelozerr
Copy link
Contributor

Bad perfomance when working with non quarkus/MP projects

See redhat-developer/vscode-quarkus#240

Signed-off-by: azerr azerr@redhat.com

@angelozerr
Copy link
Contributor Author

At first, to test this PR you need the vscode-quarkus PR https://github.com/redhat-developer/vscode-quarkus/pull/242/files

To test this PR:

  • check that diagnostics, code action is working for a MP/Quarkus project
  • open a Java file which doesn't belong to a MP project (ex : Lemminx) an check that in Quarkus Tools trace you have none microprofile/java/* trace. The only trace with microprofile is microprofile/java/projectLabels (used to collect labels of the project of the java file). This service should for the first java file which belongs to the project.

An avanced test, is to change the pom.xml dependency by adding a MP/Quarkus dependency to Lemminx and check you have traces with microprofile/java/* when a java file from Lemminx is changed (codeAction, codelens, Hover, etc).

@fbricon could you give me feedback about this PR if your performance are better?

This PR is a draft PR because I need to clean my code and write some tests.

@xorye
Copy link

xorye commented Apr 2, 2020

To test this PR:

check that diagnostics, code action is working for a MP/Quarkus project
open a Java file which doesn't belong to a MP project (ex : Lemminx) an check that in Quarkus Tools trace you have none microprofile/java/* trace. The only trace with microprofile is microprofile/java/projectLabels (used to collect labels of the project of the java file). This service should for the first java file which belongs to the project.

This works on my machine

An avanced test, is to change the pom.xml dependency by adding a MP/Quarkus dependency to Lemminx and check you have traces with microprofile/java/* when a java file from Lemminx is changed (codeAction, codelens, Hover, etc).

I am having some issues with this part. When I add Quarkus dependencies to the Lemminx pom.xml, I do not get microprofile/java/* traces on hover, codeaction etc. However, I do get them once I restart VS Code.

Same for the other way around. I get microprofile/java/* traces on Quarkus projects, but when I remove the Quarkus dependencies, I still get the microprofile/java/* traces.

Here are the Quarkus elements I added/removed in the pom.xml:
Inside the <properties> tag, I added:

    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus-plugin.version>1.3.1.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>1.3.1.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>

Inside the <dependencies> tag, I added:

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-resteasy</artifactId>
			<version>1.3.1.Final</version>
		</dependency>
		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-junit5</artifactId>
			<scope>test</scope>
			<version>1.3.1.Final</version>
		</dependency>
		<dependency>
			<groupId>io.rest-assured</groupId>
			<artifactId>rest-assured</artifactId>
			<scope>test</scope>
			<version>4.3.0</version>
		</dependency>

@angelozerr angelozerr force-pushed the java-improve-perf branch 5 times, most recently from 20e98ad to 9dde208 Compare April 4, 2020 09:54
@angelozerr
Copy link
Contributor Author

I am having some issues with this part.

It should work now, please retry

@angelozerr angelozerr force-pushed the java-improve-perf branch 2 times, most recently from 180479d to c78dd1f Compare April 6, 2020 09:04
@angelozerr angelozerr marked this pull request as ready for review April 6, 2020 09:07
@angelozerr angelozerr requested review from fbricon and xorye April 6, 2020 09:07
@angelozerr
Copy link
Contributor Author

My PR is ready now (my code should be cleaned, tests are written).

  • @fbricon please tell me if it improves the performance problem that you had had with lemMinx.
  • @xorye please redo your test, it should work now.
  • @jeffmaury pay attention, you will need to implement MicroProfileJavaProjectLabelsProvider in your LSP4E client otherwise the Java support will be broken.

@@ -31,9 +37,29 @@ public JavaProjectDelegateCommandHandler() {
public Object executeCommand(String commandId, List<Object> arguments, IProgressMonitor progress) throws Exception {
switch (commandId) {
case PROJECT_LABELS_COMMAND_ID:
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we deprecate this command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This command is used for this issue. Before this pr this command returned a List of project used by typescript. I renamed this command by adding a s. In other words the two commands are requiered

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you changed the semantic of the existing command (bad) and the 2 command names are too close (bad).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you changed the semantic of the existing command (bad)

Indeed but it's only TypeScript which consumes it and the command name uses "project" although it's for all project and not for a given project

and the 2 command names are too close (bad).

What is your suggestion?

private static final IMicroProfilePropertiesChangedListener LISTENER = (event) -> {
try {
// Execute client command with a timeout of 5 seconds to avoid blocking jobs.
JavaLanguageServerPlugin.getInstance().getClientConnection().executeClientCommand(
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be getClientConnection().sendNotification(), since we're not waiting for a response

Copy link
Contributor Author

@angelozerr angelozerr Apr 6, 2020

Choose a reason for hiding this comment

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

Yes it should be that, but there is a bug on vscode-java. I tried to fix it with the following PR redhat-developer/vscode-java#1369

@@ -31,9 +37,29 @@ public JavaProjectDelegateCommandHandler() {
public Object executeCommand(String commandId, List<Object> arguments, IProgressMonitor progress) throws Exception {
switch (commandId) {
case PROJECT_LABELS_COMMAND_ID:
Copy link
Collaborator

Choose a reason for hiding this comment

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

So you changed the semantic of the existing command (bad) and the 2 command names are too close (bad).

@@ -102,9 +102,12 @@ public void didClose(DidCloseTextDocumentParams params) {

@Override
public void didSave(DidSaveTextDocumentParams params) {
triggerValidationFor(documents.all().stream().map(TextDocument::getUri).collect(Collectors.toList()));
// validate all opened java files which belong to a MicroProfile project
triggerValidationForAll(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we're losing the info about which file was saved, it'll certainly come in handy later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we're losing the info about which file was saved, it'll certainly come in handy later

We don't need this information, the idea is when a java file is saved, all diagnostics are recomputed (to managed diagnostics for Java files which could depend on the saved java file).

You want I add the uri as parameter in triggerValidationForAll (even if it is not used)?

@angelozerr angelozerr force-pushed the java-improve-perf branch 2 times, most recently from e5949d1 to fe9a97d Compare April 6, 2020 12:20
@xorye
Copy link

xorye commented Apr 6, 2020

The fix works/looks great to me

@angelozerr
Copy link
Contributor Author

The fix works/looks great to me

Thanks for the feedback.

I have just renamed the command (with projectlabels and workspaceLabels). Please update the vscode-quarkus PR https://github.com/redhat-developer/vscode-quarkus/pull/242/files too.

@xorye could you check that the call of JDT LS of workspaceLabels works like before in TypeScript side when you collect the labels of projects.

@xorye
Copy link

xorye commented Apr 6, 2020

could you check that the call of JDT LS of workspaceLabels works like before in TypeScript side when you collect the labels of projects.

It is still working like before.

It looks like https://github.com/redhat-developer/vscode-quarkus/pull/242/files already has the updated workspaceLabels command. Is there something else I should update?

@fbricon
Copy link
Collaborator

fbricon commented Apr 7, 2020

Seems much better, but I still see microprofile/java/projectLabels requests whenever I open a new java file in LemMinX

@angelozerr
Copy link
Contributor Author

angelozerr commented Apr 7, 2020

Seems much better, but I still see microprofile/java/projectLabels requests whenever I open a new java file in LemMinX

When you open a Java file, you need to know the project URI owner. To do that, you need to trigger a JDT LS extension command. We could have a simple JDT LS command which returns the project URI of the java file uri and call after microprofile/java/projectLabels if the project is not cached, but as computing labels for a project is very quick, I consume it when file is opened.

I have not found a better way to get the project URI of the opened java file which requires a call of JDT LS command.

@fbricon
Copy link
Collaborator

fbricon commented Apr 7, 2020

ok fair enough. Since it's just a single call on open, it should be fine

@angelozerr
Copy link
Contributor Author

ok fair enough. Since it's just a single call on open, it should be fine

Yes it's that.

@angelozerr
Copy link
Contributor Author

@fbricon @xorye can we merge this PR please? I need it for the Java completion filter issue.

@fbricon fbricon merged commit 8680aa9 into redhat-developer:master Apr 7, 2020
@fbricon fbricon changed the title Bad perfomance when working with non quarkus/MP projects Bad performance when working with non quarkus/MP projects Apr 8, 2020
@fbricon fbricon added bug Something isn't working performance labels Apr 15, 2020
@fbricon fbricon added this to the v0.0.6 milestone Apr 15, 2020
@fbricon fbricon mentioned this pull request Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants