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

Perform incremental compilation using official compiler API #12

Open
fwcd opened this issue Jun 11, 2018 · 7 comments
Open

Perform incremental compilation using official compiler API #12

fwcd opened this issue Jun 11, 2018 · 7 comments
Labels
enhancement New feature or request experimental The feature is experimental and might be revoked stretch goal This feature or request might require a significant amount of time
Projects

Comments

@fwcd
Copy link
Owner

fwcd commented Jun 11, 2018

Investigate support for incremental compilation using the official Kotlin compiler API instead of the mechanism currently used (as described in the README), because this might improve performance considerably.

@fwcd fwcd added enhancement New feature or request experimental The feature is experimental and might be revoked stretch goal This feature or request might require a significant amount of time labels Jun 11, 2018
@fwcd fwcd added this to Todo in Roadmap via automation Jun 11, 2018
@fwcd
Copy link
Owner Author

fwcd commented Jun 11, 2018

This might be related:

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
	at java.util.Arrays.copyOfRange(Arrays.java:3664)
	at java.lang.String.<init>(String.java:207)
	at java.lang.String.substring(String.java:1969)
	at java.lang.String.subSequence(String.java:2003)
	at kotlin.text.StringsKt__StringsKt.commonPrefixWith(Strings.kt:775)
	at kotlin.text.StringsKt__StringsKt.commonPrefixWith$default(Strings.kt:765)
	at org.javacs.kt.position.PositionKt.changedRegion(position.kt:95)
	at org.javacs.kt.CompiledFile.oldOffset(CompiledFile.kt:114)
	at org.javacs.kt.CompiledFile.parseAtPoint(CompiledFile.kt:72)
	at org.javacs.kt.signatureHelp.SignatureHelpKt.signatureHelpAt(signatureHelp.kt:22)
	at org.javacs.kt.KotlinTextDocumentService.signatureHelp(KotlinTextDocumentService.kt:128)
	at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:61)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint$$Lambda$35/698288148.apply(Unknown Source)

@apatrida
Copy link

Is incremental compilation needed for code completion or for what purpose? How does the kotlin-web-demo handle completion?

https://github.com/JetBrains/kotlin-web-demo/tree/master/versions/1.2.50/src/main/java/org/jetbrains/webdemo/kotlin/impl

@fwcd
Copy link
Owner Author

fwcd commented Jun 19, 2018

@apatrida Each file needs to be compiled to an abstract syntax tree by the Kotlin compiler frontend. Using the AST, the language server can provide document symbols, code completion, hover and more.

The naive solution to this problem would be to compile the entire file every time the user makes an edit, but that would be extremly slow (and make your editor feel laggy). To address this problem, the language server currently extracts the expression around the cursor, puts it into a small "fake" file and tells the compiler to compile the "fake" file. Still, it would probably be better to use official compiler APIs as mentioned in the issue description.

The Kotlin demo seems to be promising in terms of performance, I will take a closer look at it soon.

@Strum355
Copy link
Contributor

I don't know well enough how the current method works (lots of methods disappearing into 3rd party packages etc), but would this solve the synchronization issue where e.g. a property is referenced in one "expression" but doesnt exist yet, is added at the relevant location, yet the error that its missing still persists?

on a side note, is there a gitter or some other more convenient place where people can discuss this project with you?

@fwcd
Copy link
Owner Author

fwcd commented Oct 22, 2018

@Strum355 There is a new Gitter channel for this project:

Gitter

@xiaoyunwu
Copy link

@fwcd I am also interested in incremental compilation, and what is the newest pointers on this? Thanks.

@weilbith
Copy link

weilbith commented Sep 5, 2023

Sounds very promising to improve performance. Is it complicated to add this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request experimental The feature is experimental and might be revoked stretch goal This feature or request might require a significant amount of time
Projects
Roadmap
  
Todo
Development

No branches or pull requests

5 participants