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

completion performance: calculating constantValue is expensive #1835

Closed
testforstephen opened this issue Aug 11, 2021 · 1 comment · Fixed by #1837
Closed

completion performance: calculating constantValue is expensive #1835

testforstephen opened this issue Aug 11, 2021 · 1 comment · Fixed by #1837

Comments

@testforstephen
Copy link
Contributor

testforstephen commented Aug 11, 2021

When code completion suggests constant fields, it will resolve their values directly and display them in the label section. See the screenshot.

image

It turns out this is an expensive operation. Especially when a type contains many constant fields, resolving them all during code completion will significantly reduce performance. See the profiling result, resolving constant value for the fields of org.eclipse.jdt.internal.compiler.ast.ASTNode will cost 45% CPU time of the language server.

image

And if I set the CompletionHandler.completion as the call tree root, you can see that resolving constant field will cost more than 90% CPU time of the completion handler.
image

Suggestion: We can remove the constant value from the label part so as to avoid the expensive calculations. But keep its value in javadoc in case the user wants to see its value.

@rgrunber
Copy link
Contributor

Confirmed. A good chunk of the time generating the completion items is spent exactly as shown above. The completion description, hovering over the value seems like a better place for this.

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