replit / polygott

Base Docker image for the Repl.it evaluation server
https://replit.com
MIT License
395 stars 103 forks source link

Fix python language server being slow #239

Closed masad-frost closed 3 years ago

masad-frost commented 3 years ago

Why

We noticed a lot of slowness with python autocomplete. It seems like there's a regression with Jedi version 0.16.0+ in combination with pyls.

What changed

Downgraded jedi to version 0.15.2, the latest pyls version that supports it is 0.31.10.

pyls 0.31.10 has an issue where it depends on ujson<=1.35, it also depends on python-jsonrpc-server>=0.3.2, however new versions of python-jsonrpc-server rely on ujson>=3.0.0, leading to problems with pip installation and the packages themselves. So I had to pin python-jsonrpc-server to 0.3.2.

Things seemed to work, however, I started facing issues with some lsp features. Turns out jedi relies on parso==0.5.2 but it doesn't pin it. So I decided to pin everything that pyls & its packages rely on. When I got to a working configuration pip list and took all the packages and pinned them in an install step before installing pyls and its packages.

I split installation into separate parts, it makes things a little slower but it makes things easier to read.

Test plan

I benchmarked completions, for larger packages like pandas numpy and tensorflow this version is about 50% faster

I tested all LSP features replit supports

replbot commented 3 years ago

Good work, this PRs short and easy to review! Promoting to bop.

replbot commented 3 years ago

unbooping: approved