Windows / rls slow

When I open a rust project in vscode, or vim, the IDE is extremely slow in marking errors.

Changes take around 5-10 seconds to propagate.

A typescript project (which also uses language-server), is nearly instantaneous, or at least under a second or so.

This wouldn't be so bad if I was good at rust - make a bunch of changes and let the IDE correct me when I have a moment to think about it.

But as a part-time Rust learner who's trying to let the compiler teach me, this is almost unbearable... I need the constant feedback and iteration. These 5-10 seconds end up costing me hours in frustration.

I vaguely remember it being bad on linux as well - but maybe not as bad... I see from various google searches that it's a problem others encounter, but then core team members like @steveklabnik seem to be developing on Windows and I'm sure on very large projects - so something must be off here.

I've tried lots of things... updated rls, tinkered with some settings (like turning racer off), etc.

For what it's worth, cargo check is very quick.... MUCH quicker (on incremental rebuilds) than the IDE/rls!

Any help is appreciated!!

1 Like

I guess this is not much help, but on linux it feels slow too. Not only on start, but during normal use.

What I've noticed is, while rustc tries to be multithreaded and compiles multiple jobs at once, RLS seems to be taking just one CPU all the time. I'm pretty sure this'll be addressed eventually, but I don't know when that would be.

As a workaround, I sometimes keep the cargo watch running in another window.

1 Like

geez... this is especially awful since one of the best ways to learn rust is via the compiler :\

don't want to be that guy who just complains without offering a solution, but this is a really big deal imho.

so you work by keeping your eye on that other window, paying attention to errors and line numbers, then fixing them in the ide?

Well, I'm old-school so the IDE is actually vim, and I'm used to not having much assistance from there. Errors appearing after a while or having to look into another window and fixing the errors by that is actually improvement over what I've been using most of my life in the C/C++ world. In that context, slow RLS is just a minor annoyance for me and a great thing when it works fast. I've been using Rust at times when RLS didn't exist yet. I've learned not to write too many errors :innocent:.

But I do agree having it fast would be great improvement. And it seems people are looking into it: https://github.com/rust-lang/rls/labels/latency

I'm also using vim, and the assistance from Neoclide is amazing! Pretty much matches VSCode

If only it were fast :frowning:

For the time being, you could try intellij-rust. I find it pretty responsive (they have their own Rust grammar parser written in Kotlin).

There is a Vim emulation plugin available as well: IdeaVim - IntelliJ IDEs Plugin | Marketplace

2 Likes

I installed intellij-rust but it didn't catch any errors for me upon re-save

I wonder if altogether this is an issue with cargo workspaces?

Also thinking that just running cargo check on save, triggered via some watcher like chokidar-cli, could be helpful (since cargo check is fast) ... won't be in the ide, but at least good info..

You can enable this in intellij-rust and get highlighting in the IDE pane (it's just not on by default):

rust2

2 Likes

At a very rough 2 minute glance that does seem to do the trick!!

Might switch to intellij after all... off-topic but I'm wondering if there's a good vim -> intellij switching guide out there... e.g. mapping ctrl-p to search, having tabs of splits instead of splits of tabs, etc.

1 Like

You can give a try to future rls 2.0: GitHub - rust-lang/rust-analyzer: A Rust compiler front-end for IDEs

It does not parse all Rust syntax yet, but it is at least usable in compare with rls 1.0

2 Likes

@dakom the main thing to do would be to install Idea Vim plugin.

However, if you want to use IntelliJ efficiently, the best way is probably to learn IntelliJ way first, and then to try to configure your own mix of Vim and Intellij, rather than to try to turn IntelliJ into Vim from the start. Vim is much better Vim than IntelliJ, obviously, but IntelliJ has a lot of really useful features which have no analogues in vim.

For example, some expert IntelliJ users tend to disable tabs completely, because there are much better ways to navigate in code.

This presentation is a nice guide to most important stuff that's available:

And yeah, rust-analyzer is also a thing now, but it's a super in-progress project :slight_smile:

2 Likes

FYI - aside for the "not to write too many errors" part I've pretty much settled into the same groove as this for now.

It's actually kindof nice now that I don't expect anything from the IDE - and I love the freedom to use (neo)vim proper for jumping around text quickly- and for lifetime errors anyway it's helpful to see the "wall of text" in a separate window.

One thing I do though is have a separate window open for running cargo build or watch, via watchexec so I can customize the command a bit more easily (e.g. have it run stuff through npm for webassembly needs, not just cargo commands)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.