sway icon indicating copy to clipboard operation
sway copied to clipboard

Further optimisations for compilation events triggered by the language server.

Open JoshuaBatty opened this issue 2 years ago • 0 comments

Here is a list of optimisations that can be made to improve the responsiveness of the language server in response to did change events. Times are measured against the benchmark example in sway-lsp tests.

  • [x] Wrap the programs_cache from the QE around an Arc 23.015ms | #5550
  • [x] Disable running DCA, control flow analysis?, for didChange events 39.544ms #5555
  • [x] Disable running collect_types_metadata for didChange events 3.522ms #5555
  • [x] Only write the diagnostics res to self.diagnostics.write() on didSave 21.135ms #5555
  • [x] Don’t write TokenMap or Metrics into an intermediate copy and then write back to the original in write_parse_result | see if we can write to them directly. 36.635ms #5516
  • [x] Cache document::mark_file_as_dirty at the beginning of didChange 708.625µs #6297
  • [x] Optimise uri_and_session_from_workspace function by caching results 575.667µs #6444
  • [ ] Write changes to memory instead of disk in write_changes_to_file func 3.387ms
  • [x] Cache the BuildPlan instead of creating on before compilation 2.425ms #5462
  • [x] We clear the whole TokenMap and traverse and repopulate the modules alongside the users workspace. We should only need to do this once. #6292 8.674ms
  • [x] Possibly run parse_ast_to_typed_tokens using a rayon par iter? (139.6ms → 127.7ms) | #5473
  • [x] Use rayon par_iters in the traverse::typed_tree module. We are doing this in traverse::parsed_tree which takes 11.3ms while typed traverse takes 140ms | #5487

JoshuaBatty avatar Jan 10 '24 01:01 JoshuaBatty