sublimelsp / LSP-rust-analyzer

Convenience package for rust-analyzer
MIT License
69 stars 11 forks source link

low responsiveness with enabled inlay hints #89

Closed Levitanus closed 1 year ago

Levitanus commented 1 year ago

I'm not sure if this is an issue of the plugin itself, but not LSP total. As, I turned back from VSCode to ST4 exactly, as it was not so responsive, as ST. But, after a couple of days of rust programming in ST, I missed inlay hints, so, turned them on. This dramatically decreased response time of the editor (probably, fps). Currently, I see no exact reason for such behavior, but it presents.

This «freezing» is not dependent on timeout preferences:

{
    "diagnostics_delay_ms": 2000,
    "diagnostics_additional_delay_auto_complete_ms": 1000,
}

FPS while displaying hints:

Frame time exceeded 60hz: 111ms
fps: 18.3 average: 10ms
Frame time exceeded 60hz: 178ms
fps: 26.8 average: 12ms
Frame time exceeded 60hz: 57ms
fps: 9.3 average: 26ms
Frame time exceeded 60hz: 176ms
Frame time exceeded 60hz: 22ms
Frame time exceeded 60hz: 219ms

And while not:

fps: 17 average: 3ms
fps: 53.2 average: 4ms
fps: 18.8 average: 4ms
fps: 11.8 average: 5ms
fps: 15.4 average: 5ms
fps: 29.9 average: 3ms
fps: 19.2 average: 3ms
fps: 18.8 average: 4ms
fps: 27.7 average: 3ms
fps: 55.5 average: 4ms
fps: 37.1 average: 3ms
fps: 26.6 average: 2ms
fps: 43.9 average: 0ms

Plugin Event Profile:

This list shows how much time each plugin has taken to respond to each event:

on_activated:
    Default.history_list: 0.007s total, mean: 0.000s, max: 0.000s
    DiffView.util.view_finder: 0.000s total, mean: 0.000s, max: 0.000s
    FileDiffs.file_diffs: 0.006s total, mean: 0.000s, max: 0.000s

on_close:
    Default.settings: 0.000s total, mean: 0.000s, max: 0.000s
    LSP.plugin.documents: 0.000s total, mean: 0.000s, max: 0.000s
    SublimeREPL.sublimerepl: 0.000s total, mean: 0.000s, max: 0.000s

on_hover:
    Default.symbol: 0.094s total, mean: 0.001s, max: 0.086s
    LSP.plugin.documents: 0.045s total, mean: 0.000s, max: 0.008s
    Terminus.terminus.mouse: 0.001s total, mean: 0.000s, max: 0.000s

on_load:
    Default.exec: 0.016s total, mean: 0.002s, max: 0.007s
    KSP (Kontakt Script Processor).ksp_plugin: 0.000s total, mean: 0.000s, max: 0.000s
    LSP.boot: 0.000s total, mean: 0.000s, max: 0.000s
    PyCover.PyCover: 0.000s total, mean: 0.000s, max: 0.000s
    ReaSyntax.ReaSyntax: 0.000s total, mean: 0.000s, max: 0.000s

on_modified:
    Default.history_list: 0.177s total, mean: 0.000s, max: 0.002s
    Default.settings: 0.001s total, mean: 0.000s, max: 0.000s
    PackageResourceViewer.package_resource_viewer: 0.104s total, mean: 0.000s, max: 0.010s
    Terminus.terminus.event_listeners: 0.008s total, mean: 0.000s, max: 0.000s

on_post_save:
    MarkdownPreview.markdown_preview: 0.022s total, mean: 0.001s, max: 0.016s

on_post_text_command:
    CppToolkit.cpp_refactor: 0.002s total, mean: 0.000s, max: 0.000s
    Default.history_list: 0.025s total, mean: 0.000s, max: 0.000s
    Default.paste_from_history: 0.009s total, mean: 0.000s, max: 0.001s
    LSP.plugin.documents: 0.012s total, mean: 0.000s, max: 0.005s
    Terminus.terminus.clipboard: 0.045s total, mean: 0.000s, max: 0.016s
    Terminus.terminus.event_listeners: 0.012s total, mean: 0.000s, max: 0.005s

on_post_window_command:
    LSP.boot: 0.001s total, mean: 0.000s, max: 0.000s

on_pre_close:
    Default.history_list: 0.002s total, mean: 0.000s, max: 0.000s
    Default.settings: 0.003s total, mean: 0.001s, max: 0.001s
    LSP.boot: 0.000s total, mean: 0.000s, max: 0.000s
    Terminus.terminus.event_listeners: 0.000s total, mean: 0.000s, max: 0.000s

on_pre_close_window:
    LSP.boot: 0.005s total, mean: 0.002s, max: 0.002s

on_pre_save:
    HTMLBeautify.HTMLBeautify: 0.001s total, mean: 0.000s, max: 0.000s
    LuaFormat.LuaFormat: 0.004s total, mean: 0.000s, max: 0.002s
    PackageResourceViewer.package_resource_viewer: 0.001s total, mean: 0.000s, max: 0.000s
    PyYapf Python Formatter.PyYapf: 0.032s total, mean: 0.001s, max: 0.023s
    Python Fix Imports.python_fiximports: 0.000s total, mean: 0.000s, max: 0.000s

on_query_completions:
    CSS.css_completions: 0.035s total, mean: 0.000s, max: 0.001s
    CSS3.css3_completions: 0.057s total, mean: 0.000s, max: 0.008s
    HTML.html_completions: 0.016s total, mean: 0.000s, max: 0.000s
    HTML5.html_completions: 0.032s total, mean: 0.000s, max: 0.011s
    KSP (Kontakt Script Processor).ksp_plugin: 0.044s total, mean: 0.000s, max: 0.014s
    LSP.plugin.documents: 0.030s total, mean: 0.000s, max: 0.001s
    LuaComplete.LuaComplete: 0.018s total, mean: 0.000s, max: 0.005s
    SublimeREPL.completions: 0.039s total, mean: 0.000s, max: 0.010s

on_query_context:
    Default.block: 0.008s total, mean: 0.000s, max: 0.000s
    DiffView.DiffView: 0.007s total, mean: 0.000s, max: 0.000s
    LSP.plugin.documents: 0.011s total, mean: 0.000s, max: 0.000s
    Terminus.terminus.query: 0.444s total, mean: 0.000s, max: 0.041s

on_selection_modified:
    Default.history_list: 0.301s total, mean: 0.000s, max: 0.001s
    SublimeREPL.sublimerepl: 0.188s total, mean: 0.000s, max: 0.022s
    Terminus.terminus.event_listeners: 0.011s total, mean: 0.000s, max: 0.000s

on_text_changed:
    LSP.plugin.documents: 0.270s total, mean: 0.000s, max: 0.017s

on_text_command:
    CppToolkit.cpp_refactor: 0.002s total, mean: 0.000s, max: 0.000s
    Default.history_list: 0.061s total, mean: 0.000s, max: 0.000s
    KSP (Kontakt Script Processor).ksp_plugin: 0.002s total, mean: 0.000s, max: 0.000s
    LSP.plugin.documents: 0.003s total, mean: 0.000s, max: 0.000s
    SublimeREPL.sublimerepl: 0.014s total, mean: 0.000s, max: 0.005s
    Terminus.terminus.event_listeners: 0.066s total, mean: 0.000s, max: 0.017s
    Terminus.terminus.mouse: 0.005s total, mean: 0.000s, max: 0.000s

on_window_command:
    Default.history_list: 0.009s total, mean: 0.000s, max: 0.000s
    Terminus.terminus.event_listeners: 0.001s total, mean: 0.000s, max: 0.000s
rchl commented 1 year ago

LSP just creates Phantoms using ST's API and then it's up to ST to render them as efficiently as possible. So it's likely nothing that we can do about.

I did test using pretty extreme case and did get worse results but not as bad as you:

Frame time exceeded 60hz: 23ms
Frame time exceeded 60hz: 18ms
fps: 80.6 average: 8ms
fps: 63.4 average: 11ms
fps: 66.1 average: 10ms
fps: 64.8 average: 9ms
Frame time exceeded 60hz: 17ms
Frame time exceeded 60hz: 18ms

vs. no phantoms:

fps: 68.7 average: 3ms
fps: 80.8 average: 3ms
fps: 63.5 average: 4ms
fps: 64.2 average: 4ms

Screenshot 2023-01-15 at 22 38 34

This is on a standard Macbook M1 and 1440 screen vertical resolution.

This can of course vary per GPU, CPU and OS. In any case, this is something that should be reported to ST (https://github.com/sublimehq/sublime_text/issues/new/choose), if not already. Though it would be more likely to looked at if it can be reproduced easily.

Maybe at least show screen recording so that we know what you are looking at. There might be something specific that causes worse performance.

Levitanus commented 1 year ago

Thank you, let's close it here :)