elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

Spawns multiple code_helper processes and beam.smp with extremely high CPU usage.

Open sergiotapia opened this issue 8 years ago • 19 comments

I had to disable this excellent extension on VSCode because it was causing such high CPU usage, it would freeze my entire computer.

In Activity Monitor, I see about 9 Code Helper processes, and a beam.smp with around %200+ CPU usage. Force quitting VSCode and terminating all code helper processes immediately fixed the issue.

To reproduce just try to save any Elixir file with bugs, typos or calling non-existing functions with formatOnSave enabled. It'll show red squiggly lines, right. And after that, fix the issues and save, after a few minutes you'll see the slowdown start to ramp up until the computer is unusable.

Unfortunately I can't provide more details than that because I'm not sure what kind of debug info you need.

I hope you can reproduce the issue and find the root cause, I love this extension!

sergiotapia avatar Feb 27 '18 13:02 sergiotapia

Hm. Can you post a project repo on Github that reproduces it?

My first guess with high CPU usage is to blame Dialyzer. Try setting elixirLS.dialyzerEnabled to false and see if it remains a problem. Usually, you'll see high CPU usage during the initial PLT generation and project analysis on big projects, but after the initial analysis it isn't usually a problem.

I'm not sure what the "code helper" processes are, they're either spawned by VS Code itself or another extension.

JakeBecker avatar Feb 27 '18 17:02 JakeBecker

I agree, great extension. Unfortunately, I'm seeing this as well with elixirLS.dialyzerEnabled set to false.

dsnider avatar Apr 20 '18 14:04 dsnider

Check the output log by opening View > Output and selecting "ElixirLS" in the dropdown. Is there anything there that looks relevant?

JakeBecker avatar Apr 20 '18 17:04 JakeBecker

I get the problem of extremely high memory usage by beam.smp. I set elixirLS.dialyzerEnabled to false and that fixed the problem for me.

I would add that with the default settings, I didn't see anything unusual in the View > Output of "ElixirLS".

jhaddow avatar Apr 20 '18 22:04 jhaddow

To follow up on this, a full restart with elixirLS.dialyzerEnabled to false did address the high CPU issue. I initially tried a reload and that did not work for me.

dsnider avatar May 20 '18 18:05 dsnider

This did fix some of my projects, but not all. One project I'm working on has a custom template compiler, and currently, it recompiles the target templates without looking to see if there were actual changes. This compiler generates new output templates which trigger ElixirLS to re-compile and the hamster wheel goes around again.

We essentially want to ignore file changes that are a result of compiling. Would it be possible to ignore changes while compiling for such situations? Or, perhaps a configurable compilation hold-off?

dsnider avatar May 23 '18 23:05 dsnider

@dsnider vscode-elixir-ls sets up filesystem watchers here using createFileSystemWatcher. Fortunately, vscode allows to exclude files from watchers created using that function. You need to set files.watcherExclude in your vscode config to stop the watcher from picking up changes for .*ex files you're generating during compilation, and then infinite compile will stop.

michallepicki avatar Jul 31 '18 07:07 michallepicki

I was having the same issue with a veeery simple directory, just a .exs file with a module and another with tests (code katas from exercism).

At first ElixirLS was raising an error due to the lack of a mix.exs file. I was just ignoring it as I didn't need a whole mix project.

But then I made a try and created a another mix project to see if I could play a little the debugger feature. ElixirLS kicked, generated PLT and I could use some of the features (unfortunatelly didn't figured out how to setup the debugger).

The issue happened after all that in another simple project (again - only 2 .exs files), for some reason, having used the extension in a full mix project didn't raise the error, but it raised the CPU usage to the clouds! My MBP fan went nuts and CPU usage was constantly around 100%

monitor_de_atividade__todos_os_processos__e_twitter

I'll try to disable and reenable dialyzer to see if something changes.

halian-vilela avatar Aug 01 '18 06:08 halian-vilela

There was a dialyzer bug that caused infinite analysis triggered by code in elixir 1.7.0. Please make sure you use 1.7.1 or 1.6.x to eliminate this particular issue.

michalmuskala avatar Aug 01 '18 09:08 michalmuskala

Fantastic, seems to have solved the issue...

As they would say here in Brazil: "Ahhh moleke!!!" 😄

halian-vilela avatar Aug 01 '18 12:08 halian-vilela

vc ta me tirando rapaz!? jajaja

Thanks dudes, great job!

sergiotapia avatar Aug 01 '18 16:08 sergiotapia

The issue still persists on Elixir 1.7.2 (compiled with Erlang/OTP 20). I'm using Fedora Linux with Neovim and ALE plugin. How can I disable elixirLS.dialyzerEnabled? There's no config.json file in the "elixir-ls/rel" folder.

UPDATE: I fixed it. I found this in the ALE documentation:

g:ale_elixir_elixir_ls_config g:ale_elixir_elixir_ls_config b:ale_elixir_elixir_ls_config Type: |Dictionary| Default: {} Dictionary containing configuration settings that will be passed to the language server. For example, to disable Dialyzer: > { \ 'elixirLS': { \ 'dialyzerEnabled': v:false, \ }, \ } < Consult the ElixirLS documentation for more information about settings.

I'm just wondering is there any disadvantages on disabling the dialyzer?

zoliky avatar Nov 30 '18 16:11 zoliky

just getting my feet wet with elixir, installed the plugin and having the same issues.

g5becks avatar Dec 04 '18 10:12 g5becks

Dialyzer is not ready for primetime and breaks down frequently. I suggest disabling dialyzer. Here's how to do it in VSCode: https://dev.to/sergio/setting-up-vs-code-for-elixir-development-59aa

sergiotapia avatar Dec 04 '18 17:12 sergiotapia

Having similar issues, also disabling dialyzer helps but after some time VS Code loses the ability for code completion. After enabling I have the following picture

Initial indexing

screenshot 2018-12-24 at 18 44 52

After indexing finished

It takes some time to wrap up indexing. screenshot 2018-12-24 at 18 45 00

Jump to source

screenshot 2018-12-24 at 18 46 32

System specs

  • OS: OSX Mojave 10.14.2,
  • Elixir: 1.7.4 (compiled with Erlang/OTP 21),
  • VS Code: 1.30.1,
  • Project type: umbrella project, contains phoenix applications, separate ecto repository (https://github.com/lbrty/secure-idp-backend),

sultaniman avatar Dec 24 '18 17:12 sultaniman

I suspect this is related to an open VS Code Issue. My CPU spikes even when extensions are disabled, and even when I'm saving changes to package.json.

type1fool avatar Dec 28 '18 22:12 type1fool

Was having the CPU pegging issue, as well. Using vim + ALE. The comment that @zoliky made pointing towards the ALE ElixirLS option to disable Dialyzer solved the CPU pegging issue.

jsimpson avatar Apr 12 '19 20:04 jsimpson

Recent ALE issue related to this: https://github.com/w0rp/ale/issues/2397

Stratus3D avatar Apr 12 '19 21:04 Stratus3D

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over at elixir-lsp/elixir-ls. Updates will continue to be published from that repo to the original VS Code extension, so no need to switch plugins if you're using VS Code.

To avoid inundating the new maintainers with issues, please verify that your issue persists with the latest version of the extension (which is published from the new repo) before re-filing your issue there.

Thanks for using ElixirLS!

JakeBecker avatar Apr 16 '20 03:04 JakeBecker