0

I am working to provide semantic coloring for my language for VSCode client and java based language server using lsp4j. But for large files syncing the entire document has performance lag which becomes unacceptable for larger documents. Can I get some insights for various options available?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Have you profiled your server code (derived from https://github.com/eclipse/lsp4j/blob/af368bdeb4450613a8676cc21757dcc31bba53ea/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/services/TextDocumentService.java) and see how it computes and responds to requests for semantic tokens? – kaby76 Aug 27 '21 at 12:39
  • Yes. It takes maximum time in rebuilding the AST for the new version of the document. – NIKHIL DUBEY Aug 30 '21 at 07:00
  • There are many things you could look at. Are you compiling the doc with every call? For example, the opening sequence is TextDocumentDidOpen, TextDocumentDocumentSymbol, SemanticTokens. Why would it recompute the AST when it was already done for TextDocDocSymbol? Are you recompiling included files? Is the parser constructing the AST while parsing, or is the parser first constructing a parse tree, then converting to an AST? Try changing how you allocated and represent the AST, from GC'ed data structures to a simple heap-based allocator that you write (might not be easy with Java)? – kaby76 Aug 30 '21 at 11:37

0 Answers0