castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

High energy impact (vscode on macOs) #117

Closed giovdk21 closed 5 years ago

giovdk21 commented 5 years ago

Might be related to #109, although I've been noticing this for a while and did not get notified about it. (I just spotted it looking at the activity monitor)

OS: macOS 10.14.4 (18E226) VSCode: 1.34.0 vscode-solargraph: 0.19.6 solargraph (gem): 0.32.3

When I open a ruby project (even a small one), with the solargraph extension enabled, the energy impact reported by activity monitor is very high (between 20 and 40% on average).

It then drops (to about 3%) if I close the project (while having other non-ruby projects open)

castwide commented 5 years ago

Thanks. I was finally able to reproduce this issue on a MacBook. I'll look further into it.

castwide commented 5 years ago

The root cause appears to be the client-server interface. Solargraph uses Backport for event-driven IO. Backport was performing a lot of unnecessary polling, resulting in activity on threads that could have easily been sitting idle. My MacBook would show the Solargraph process at 10-12% CPU usage even when VS Code was sitting in the background.

This morning I released a new version of Backport that handles IO much more efficiently. Using the new version, Solargraph idles on my MacBook at about 1%. The change is in Solargraph's master branch. I expect to update the gem tomorrow.

castwide commented 5 years ago

This update also appears to have an impact on my Windows workstation. The polling problem wasn't apparent there, because the processor has enough power to show the Solargraph process idling at 0%. But under heavy activity, its CPU usage is decreased by about 25%.

giovdk21 commented 5 years ago

That's great, many thanks!

Will test it in the upcoming days and I'll let you know

castwide commented 5 years ago

Gem v0.32.4 is published.

giovdk21 commented 5 years ago

Just tested it quickly and seems to be working fine! Energy impact is now < 5% when idle. Thanks again