Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory and High CPU Usage #1101

Open
2 tasks done
yordis opened this issue Apr 18, 2024 · 53 comments
Open
2 tasks done

Memory and High CPU Usage #1101

yordis opened this issue Apr 18, 2024 · 53 comments

Comments

@yordis
Copy link

yordis commented Apr 18, 2024

I was working on the Tesla package and went to sleep. When I resumed work, I noticed that my computer was almost unresponsive. The extension had consumed all available RAM and spiked the CPU.

This is not the first time it has happened; just that this time, I didn't close it or click on the extension's notification complaining about compilation errors or something else.

Environment

  • Elixir & Erlang versions: Elixir 1.16.2, Erlang/OTP 26
  • VSCode ElixirLS version: v0.20.0
  • Operating System Version: macOS 14.2.1 (Intel)

Troubleshooting

  • Restart your editor (which will restart ElixirLS) sometimes, fixes issues
  • Stop your editor, remove the entire .elixir_ls directory, then restart your editor

Crash report template

Screenshot 2024-04-18 at 10 48 28 AM
Screenshot 2024-04-18 at 10 48 37 AM

View Logs ``` [Info - 12:20:25 AM] Compile took 6920 milliseconds [Info - 12:20:25 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:20:25 AM] Starting build with MIX_ENV: test MIX_TARGET: host [Info - 12:20:25 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:20:25 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 25ms [Info - 12:20:32 AM] Compile took 6413 milliseconds [Info - 12:20:32 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:20:32 AM] [ElixirLS Dialyzer] Found 1 changed files in 76 milliseconds [Info - 12:20:32 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:20:33 AM] [ElixirLS Dialyzer] Analysis finished in 449 milliseconds [Info - 12:20:33 AM] Dialyzer analysis is up to date [Info - 12:20:33 AM] Success typings computed in 88ms [Info - 12:20:34 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:20:34 AM] Success typings computed in 46ms [Info - 12:20:35 AM] [ElixirLS Dialyzer] Done writing manifest in 1863 milliseconds. [Info - 12:20:41 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:20:46 AM] Compile took 5173 milliseconds [Info - 12:20:46 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:20:46 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:20:46 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms [Info - 12:20:46 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:20:46 AM] [ElixirLS Dialyzer] Found 1 changed files in 69 milliseconds [Info - 12:20:46 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:20:47 AM] [ElixirLS Dialyzer] Analysis finished in 373 milliseconds [Info - 12:20:47 AM] Dialyzer analysis is up to date [Info - 12:20:47 AM] Success typings computed in 76ms [Info - 12:20:47 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:20:48 AM] [ElixirLS Dialyzer] Done writing manifest in 1558 milliseconds. [Info - 12:20:52 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:21:01 AM] Compile took 8649 milliseconds [Info - 12:21:01 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:21:01 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:21:01 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms [Info - 12:21:01 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:21:01 AM] [ElixirLS Dialyzer] Found 1 changed files in 197 milliseconds [Info - 12:21:01 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:21:02 AM] [ElixirLS Dialyzer] Analysis finished in 429 milliseconds [Info - 12:21:02 AM] Dialyzer analysis is up to date [Info - 12:21:02 AM] Success typings computed in 92ms [Info - 12:21:03 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:21:03 AM] Success typings computed in 62ms [Info - 12:21:04 AM] [ElixirLS Dialyzer] Done writing manifest in 1872 milliseconds. Received $/cancelRequest for unknown request id: 2155 [Info - 12:21:11 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:21:21 AM] Compile took 9616 milliseconds [Info - 12:21:21 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:21:21 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:21:21 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms [Info - 12:21:21 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:21:21 AM] [ElixirLS Dialyzer] Found 1 changed files in 74 milliseconds [Info - 12:21:22 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:21:22 AM] [ElixirLS Dialyzer] Analysis finished in 396 milliseconds [Info - 12:21:22 AM] Dialyzer analysis is up to date [Info - 12:21:22 AM] Success typings computed in 75ms [Info - 12:21:22 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:21:23 AM] [ElixirLS Dialyzer] Done writing manifest in 1416 milliseconds. [Info - 12:21:29 AM] Success typings computed in 136ms [Info - 12:21:41 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:21:48 AM] Compile took 6908 milliseconds [Info - 12:21:48 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:21:48 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:21:48 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms [Info - 12:21:48 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:21:48 AM] [ElixirLS Dialyzer] Found 1 changed files in 143 milliseconds [Info - 12:21:48 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:21:49 AM] [ElixirLS Dialyzer] Analysis finished in 576 milliseconds [Info - 12:21:49 AM] Dialyzer analysis is up to date [Info - 12:21:49 AM] Success typings computed in 81ms [Info - 12:21:50 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:21:50 AM] Success typings computed in 96ms [Info - 12:21:51 AM] [ElixirLS Dialyzer] Done writing manifest in 1615 milliseconds. [Info - 12:22:17 AM] Success typings computed in 59ms [Info - 12:22:23 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:22:30 AM] Compile took 6522 milliseconds [Info - 12:22:30 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:22:30 AM] Starting build with MIX_ENV: test MIX_TARGET: host [Info - 12:22:30 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:22:30 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 2ms [Info - 12:22:36 AM] Compile took 5908 milliseconds [Info - 12:22:36 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:22:36 AM] [ElixirLS Dialyzer] Found 1 changed files in 180 milliseconds [Info - 12:22:36 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:22:37 AM] [ElixirLS Dialyzer] Analysis finished in 386 milliseconds [Info - 12:22:37 AM] Dialyzer analysis is up to date [Info - 12:22:37 AM] Success typings computed in 80ms [Info - 12:22:37 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:22:38 AM] Success typings computed in 111ms [Info - 12:22:38 AM] [ElixirLS Dialyzer] Done writing manifest in 1640 milliseconds. [Info - 12:22:47 AM] Success typings computed in 51ms [Info - 12:23:10 AM] Success typings computed in 195ms [Info - 12:23:16 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:23:23 AM] Compile took 6846 milliseconds [Info - 12:23:23 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:23:23 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:23:23 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:23:23 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms [Info - 12:23:23 AM] [ElixirLS Dialyzer] Found 1 changed files in 71 milliseconds [Info - 12:23:24 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:23:24 AM] [ElixirLS Dialyzer] Analysis finished in 449 milliseconds [Info - 12:23:24 AM] Dialyzer analysis is up to date [Info - 12:23:24 AM] Success typings computed in 97ms [Info - 12:23:25 AM] [ElixirLS Dialyzer] Writing manifest... [Info - 12:23:26 AM] [ElixirLS Dialyzer] Done writing manifest in 1858 milliseconds. [Info - 12:24:25 AM] Success typings computed in 60ms [Info - 12:24:27 AM] Starting build with MIX_ENV: test MIX_TARGET: host Compiling 1 file (.ex) [Info - 12:24:37 AM] Compile took 9439 milliseconds [Info - 12:24:37 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:24:37 AM] Starting build with MIX_ENV: test MIX_TARGET: host [Info - 12:24:37 AM] [ElixirLS WorkspaceSymbols] 1 modules need reindexing [Info - 12:24:37 AM] [ElixirLS WorkspaceSymbols] 2 symbols added to index in 1ms Received $/cancelRequest for unknown request id: 2272 [Info - 12:24:47 AM] Compile took 9905 milliseconds [Info - 12:24:47 AM] [ElixirLS WorkspaceSymbols] Updating index... [Info - 12:24:47 AM] Starting build with MIX_ENV: test MIX_TARGET: host [Info - 12:24:47 AM] [ElixirLS WorkspaceSymbols] 0 modules need reindexing [Info - 12:24:47 AM] [ElixirLS WorkspaceSymbols] 0 symbols added to index in 0ms [Info - 12:24:58 AM] Compile took 11430 milliseconds [Info - 12:24:58 AM] [ElixirLS Dialyzer] Checking for stale beam files [Info - 12:24:59 AM] [ElixirLS Dialyzer] Found 1 changed files in 120 milliseconds [Info - 12:24:59 AM] [ElixirLS Dialyzer] Analyzing 1 modules: [Tesla.AdapterCase.SSL] [Info - 12:24:59 AM] [ElixirLS Dialyzer] Analysis finished in 433 milliseconds [Info - 12:24:59 AM] Dialyzer analysis is up to date [Info - 12:24:59 AM] Success typings computed in 116ms [Info - 12:25:00 AM] [ElixirLS Dialyzer] Writing manifest... [Warn - 12:25:00 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory) │ 1 │ defmodule Tesla.Adapter.HttpcTest do │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ └─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:01 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:01 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Info - 12:25:01 AM] [ElixirLS Dialyzer] Done writing manifest in 2000 milliseconds.
[Warn - 12:25:01 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:02 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:03 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:03 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:04 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:04 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:05 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:05 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:06 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Warn - 12:25:06 AM] warning: redefining module Tesla.Adapter.HttpcTest (current version defined in memory)

1 │ defmodule Tesla.Adapter.HttpcTest do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

└─ test/tesla/adapter/httpc_test.exs:1: Tesla.Adapter.HttpcTest (module)

[Error - 10:49:02 AM] Server process exited with signal SIGKILL.
[Info - 10:49:02 AM] Connection to server got closed. Server will restart.
true
Running /Users/ubi/.vscode/extensions/jakebecker.elixir-ls-0.20.0/elixir-ls-release/launch.sh
Preferred shell is zsh, relaunching
Looking for ASDF install
ASDF install found in /Users/ubi/.asdf/asdf.sh, sourcing
Installing ElixirLS release v0.20.0
Running in /Users/ubi/Developer/github.com/elixir-tesla/tesla
Install complete
[Info - 10:49:06 AM] Started ElixirLS v0.20.0
[Info - 10:49:06 AM] Running in /Users/ubi/Developer/github.com/elixir-tesla/tesla
[Info - 10:49:06 AM] ElixirLS built with elixir "1.16.2" on OTP "26"
[Info - 10:49:06 AM] Running on elixir "1.16.2 (compiled with Erlang/OTP 24)" on OTP "26"
[Info - 10:49:06 AM] Protocols are not consolidated
[Info - 10:49:06 AM] Elixir sources not found (checking in /home/runner/work/elixir/elixir). Code navigation to Elixir modules disabled.
[Info - 10:49:06 AM] Received client configuration via workspace/configuration
%{"additionalWatchedExtensions" => [], "autoBuild" => true, "autoInsertRequiredAlias" => true, "dialyzerEnabled" => true, "dialyzerFormat" => "dialyxir_long", "dialyzerWarnOpts" => [], "enableTestLenses" => false, "envVariables" => %{}, "fetchDeps" => false, "languageServerOverridePath" => "", "mixEnv" => "test", "mixTarget" => "", "projectDir" => "", "signatureAfterComplete" => true, "suggestSpecs" => true, "trace" => %{"server" => "off"}}
[Info - 10:49:08 AM] Registering for workspace/didChangeConfiguration notifications
[Info - 10:49:08 AM] Starting build with MIX_ENV: test MIX_TARGET: host
[Info - 10:49:08 AM] client/registerCapability succeeded
[Info - 10:49:08 AM] Registering for workspace/didChangeWatchedFiles notifications
[Info - 10:49:08 AM] client/registerCapability succeeded
[Warn - 10:49:08 AM] error: module Tesla.AdapterCase is not loaded and could not be found
└─ nofile: Tesla.Adapter.HttpcTest (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Adapter.HttpcTest (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 1, line: 4, column: 54], line: 4, column: 3], [{:aliases, [last: [line: 4, column: 13], line: 4, column: 7], [:Tesla, :AdapterCase]}, [adapter: {:aliases, [last: [line: 4, column: 49], line: 4, column: 35], [:Tesla, :Adapter, :Httpc]}]]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla.AdapterCase.Basic is not loaded and could not be found
└─ nofile: Tesla.Adapter.HttpcTest (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Adapter.HttpcTest (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 1, line: 5, column: 30], line: 5, column: 3], [{:aliases, [last: [line: 5, column: 25], line: 5, column: 7], [:Tesla, :AdapterCase, :Basic]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla.AdapterCase.Multipart is not loaded and could not be found
└─ nofile: Tesla.Adapter.HttpcTest (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Adapter.HttpcTest (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 1, line: 6, column: 34], line: 6, column: 3], [{:aliases, [last: [line: 6, column: 25], line: 6, column: 7], [:Tesla, :AdapterCase, :Multipart]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla.AdapterCase.StreamRequestBody is not loaded and could not be found
└─ nofile: Tesla.Adapter.HttpcTest (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Adapter.HttpcTest (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 2, line: 7, column: 42], line: 7, column: 3], [{:aliases, [last: [line: 7, column: 25], line: 7, column: 7], [:Tesla, :AdapterCase, :StreamRequestBody]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla.AdapterCase.SSL is not loaded and could not be found
└─ nofile: Tesla.Adapter.HttpcTest (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Adapter.HttpcTest (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 1, line: 14, column: 6], line: 9, column: 3], [{:aliases, [last: [line: 9, column: 25], line: 9, column: 7], [:Tesla, :AdapterCase, :SSL]}, [ssl: [verify: :verify_peer, cacertfile: {{:., [line: 13, column: 23], [{:aliases, [last: [line: 13, column: 19], line: 13, column: 19], [:Path]}, :join]}, [closing: [line: 13, column: 90], line: 13, column: 24], [[{:to_string, [closing: [line: 13, column: 66], line: 13, column: 30], [{{:., [line: 13, column: 45], [:code, :priv_dir]}, [closing: [line: 13, column: 65], line: 13, column: 46], [:httparrot]}]}, "/ssl/server-ca.crt"]]}]]]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Info - 10:49:08 AM] Loaded DETS databases in 137ms
[Warn - 10:49:08 AM] error: module Tesla is not loaded and could not be found
└─ nofile: Tesla.Middleware.TimeoutTest.Client (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Middleware.TimeoutTest.Client (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 2, line: 5, column: 14], line: 5, column: 5], [{:aliases, [last: [line: 5, column: 9], line: 5, column: 9], [:Tesla]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla is not loaded and could not be found
└─ nofile: Tesla.Middleware.TimeoutTest.DefaultTimeoutClient (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Middleware.TimeoutTest.DefaultTimeoutClient (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 2, line: 35, column: 14], line: 35, column: 5], [{:aliases, [last: [line: 35, column: 9], line: 35, column: 9], [:Tesla]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

[Warn - 10:49:08 AM] error: module Tesla is not loaded and could not be found
└─ nofile: Tesla.Middleware.TimeoutTest.OtelTimeoutClient (module)

[Warn - 10:49:08 AM] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Tesla.Middleware.TimeoutTest.OtelTimeoutClient (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 2, line: 53, column: 14], line: 53, column: 5], [{:aliases, [last: [line: 53, column: 9], line: 53, column: 9], [:Tesla]}]}"
(elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
(elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
(elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
(elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
(elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
(elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(stdlib 5.2.1) lists.erl:1706: :lists.mapfoldl_1/3
(elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
(elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
(elixir_sense 2.0.0) lib/elixir_sense/core/metadata_builder.ex:1301: ElixirSense.Core.MetadataBuilder.pre/2

Compiling 48 files (.ex)
Generated tesla app
[Info - 10:49:13 AM] Compile took 4560 milliseconds
[Info - 10:49:13 AM] [ElixirLS WorkspaceSymbols] Indexing...
[Info - 10:49:13 AM] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info - 10:49:13 AM] [ElixirLS WorkspaceSymbols] 425 symbols added to index in 37ms
[Info - 10:49:13 AM] [ElixirLS Dialyzer] Checking for stale beam files
[Info - 10:49:13 AM] [ElixirLS Dialyzer] Found 61 changed files in 109 milliseconds
[Info - 10:49:13 AM] [ElixirLS Dialyzer] Analyzing 3 modules: [MockClient, Tesla.Env, Tesla]
[Info - 10:49:14 AM] [ElixirLS Dialyzer] Analysis finished in 792 milliseconds
[Info - 10:49:14 AM] Dialyzer analysis is up to date
[Info - 10:49:15 AM] [ElixirLS Dialyzer] Writing manifest...
[Info - 10:49:16 AM] [ElixirLS Dialyzer] Done writing manifest in 1690 milliseconds.
[Info - 10:49:17 AM] Success typings computed in 3258ms
[Info - 10:56:08 AM] Success typings computed in 42ms
[Info - 10:56:11 AM] Success typings computed in 26ms
[Info - 11:00:45 AM] Success typings computed in 52ms
[Info - 11:01:07 AM] Success typings computed in 42ms


</details>

@fnicastri
Copy link

I have the same problem, make it almost unusable.

@lukaszsamson
Copy link
Collaborator

Any way to reproduce this?

@vuluu2k
Copy link

vuluu2k commented May 4, 2024

it's up high cpu and memory when I saved

@fnicastri
Copy link

I get this behavior even with a clean phoenix project

@asantare
Copy link

asantare commented May 5, 2024

same high CPU and memory problem for me, still not sure what triggers it, I got it with a simple project.

Is there a way to log some memory/threads dump of the beam.smp when killing it?

Similar environment:

  • Elixir & Erlang versions: Elixir 1.16.2, Erlang/OTP 26
  • VSCode ElixirLS version: v0.21.0
  • Operating System Version: macOS 14.4.1 (M1)

@asantare
Copy link

asantare commented May 6, 2024

I've found a way to reproduce it:

  • I have a project with a simple module with few functions but without use directive
  • open the project in vscode
  • open the simple module
  • write use GenServer (slowly)
  • boom, the beam.smp goes high cpu and memory usage

here the log from the pluging output window:

Warn  - 07:46:13] ** (ErlangError) Erlang error: "CompileError during metadata build pre:\nnofile: cannot compile module Genetic (errors have been logged)\nast node: {:use, [end_of_expression: [newlines: 0, line: 2, column: 12], line: 2, column: 3], [{:__aliases__, [last: [line: 2, column: 7], line: 2, column: 7], [:GenSe]}]}"
    (elixir 1.16.2) src/elixir_expand.erl:96: :elixir_expand.expand/3
    (elixir 1.16.2) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
    (elixir 1.16.2) src/elixir_expand.erl:46: :elixir_expand.expand/3
    (elixir 1.16.2) src/elixir.erl:478: :elixir.quoted_to_erl/4
    (elixir 1.16.2) src/elixir.erl:346: :elixir.eval_forms/4
    (elixir 1.16.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
    (elixir 1.16.2) lib/code.ex:572: Code.validated_eval_string/3
    (elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:24: ElixirSense.Core.MacroExpander.require_and_expand/2
    (elixir 1.16.2) lib/macro.ex:640: anonymous fn/4 in Macro.do_traverse_args/4
    (stdlib 5.2.3) lists.erl:1706: :lists.mapfoldl_1/3
    (elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
    (stdlib 5.2.3) lists.erl:1706: :lists.mapfoldl_1/3
    (elixir 1.16.2) lib/macro.ex:605: Macro.do_traverse/4
    (elixir_sense 2.0.0) lib/elixir_sense/core/macro_expander.ex:18: ElixirSense.Core.MacroExpander.expand_use/4
    (elixir_sense 2.0.0) lib/elixir_sense/core/state.ex:1689: ElixirSense.Core.State.expand/3


@asantare
Copy link

asantare commented May 6, 2024

hi @lukaszsamson,
there is an issue on elixir-ls, somehow related, and a comment about the macro expansion.

How come the beam get stuck in high cpu usage (in loop?) when trying to expand a non existing macro? (from the log in previous comment it seems it tries to expand 'GenSe')
Can it be tracked/reproduced on beam side?

@lukaszsamson
Copy link
Collaborator

@asantare thanks, I can confirm there is an infinite loop issue with incomplete code

defmodule Some do
  use
  @spec my(number()) :: number()
  def my(abc) do
    abc + 1
  end
end

@lukaszsamson
Copy link
Collaborator

@yordis @fnicastri @vuluu2k are your scenarios similar to what @asantare found?

@fnicastri
Copy link

@lukaszsamson

nope, I'm sorry but I misread the topic.
Probably my case is unrelated to the extension.

In my case whenever I start a Phoenix/Ecto process in the debugger the
process start to eat all the memory.
But I have no idea if the two cases can have something in common.

image

This was now, latest stable versions of everything.

@lukaszsamson
Copy link
Collaborator

@fnicastri That's most likely unrelated. For reference #1017

@fnicastri
Copy link

@lukaszsamson

yep, it was me ;)

I thought I answered you but then I got overwhelmed by work...

@yordis
Copy link
Author

yordis commented May 6, 2024

It could definitely be a macros problem, that, it fails to compile and then it never gets to work later.

I have run into compilation issues that keeps showing notifications messages even thou it is fixed

@lukaszsamson
Copy link
Collaborator

@asantare issue fixed in elixir-lsp/elixir_sense@8ec03be

@lukaszsamson
Copy link
Collaborator

@yordis can you try attaching observer to language server? To do so

  1. Create a local setup script in $XDG_CONFIG_HOME/elixir_ls/setup.sh or $HOME/.config/elixir_ls/setup.sh (whatever is defined on your system)
  2. Enable distribution in your local setup script e.g. export ELS_ELIXIR_OPTS="--sname language_server"
  3. Restart language server
  4. Run iex in terminal iex --sname foo and :observer.start()
    You should be able to switch node to language server and inspect what is using up the resources

@yordis
Copy link
Author

yordis commented May 7, 2024

@lukaszsamson I am trying to remember to follow up on this, but it will require to wait at least until next week. Sorry!

@njwest
Copy link

njwest commented May 7, 2024

+1, massive resource usage seemingly after the last update

@wsbinette
Copy link

+1 on this as well. Killing my CPU's performance.

@mihaiphilip
Copy link

mihaiphilip commented May 7, 2024

Same here.
As soon as I type use GenServer the computer become unresponsive.
Same problem after typing use Application.
After I kill VSCode, it takes several minutes for computer to recover.
Then, after restarting VSCode, it is usable again; until I need to use another behaviour...

Edit:
Temporary solved the issue by downgrading the extension to version 0.20.0

@lukaszsamson
Copy link
Collaborator

v0.21.1 with fix for use problem has been released.

@PragTob
Copy link

PragTob commented May 8, 2024

Thanks a lot! 💚

I don't think use is the only problem though. I had it eat my entire memory again apparently on the new version and I was "only" working on seeds.exs so no use in use. It also seems to die so fast that I can't attach observer, or at least when I notice it the computer is already sluggish and then I have seconds to close vscode before all memory blows up 😅

@wsbinette
Copy link

I agree with @PragTob. It seems to get caught up on def function(), do: one line syntax as well. It kills the syntax highlighting and then my CPU goes crazy. This may be worth it's own issue report, but I'll just put this here for now.

@HarshBalyan
Copy link

Screenshot 2024-05-09 at 7 56 33 PM Screenshot 2024-05-09 at 7 54 57 PM

Let me know the logs to post

@lukaszsamson
Copy link
Collaborator

@wsbinette do you have a more complete repro? I tried def function(), do: and couldn't hit it.

@HarshBalyan please use steps from #1101 to diagnose.

@xadhoom
Copy link

xadhoom commented May 9, 2024

I'm seeing the same on v0.21.1, albeit much "slower" in memory usage growth compared to previous version.

A first check seems that what is increasing is ETS usage (most of the memory according to observer is there), will try to keep an eye on which table is increasing.

@wsbinette
Copy link

@wsbinette do you have a more complete repro? I tried def function(), do: and couldn't hit it.

I'll see if I can get a consistent repro for it 👍🏼 Might take a minute tho, sorry!

@xadhoom
Copy link

xadhoom commented May 13, 2024

A first check seems that what is increasing is ETS usage (most of the memory according to observer is there), will try to keep an eye on which table is increasing.

Follow up: ETS is indeed doing "something".

On the very same project, at startup I've 35 ETS tables with 542MB memory usage (by ETS itself). After sometime of working, I have 45 ETS tables, using ~1.2GB of memory. Some screenshots for reference (taken an startup and after a while). This happened in less than our hour.

erlang-ls-observer-ets-startup
erlang-ls-observer-ets-2
erlang-ls-observer-ets-3

There're some duplicated tables, with same number of objects and usage, but maybe is by design. I'll keep an eye on the observer, today had a crash due to after a day of work (and no observer open :( ), so It may need time to happen again.

@lukaszsamson
Copy link
Collaborator

Thanks @xadhoom Those duplicated tables are from the new incremental dialyzer. My hypothesis is that when it crashes it recreates the tables. I’ll work on a fix and until then I suggest switching back to the old dialyzer

@fnicastri
Copy link

After one hour of light editing a project.
just editing/removing Logger calls

Screenshot 2024-05-14 at 9 31 44 AM

@xadhoom
Copy link

xadhoom commented May 14, 2024

@fnicastri you can fire up the observer as explained here to check where this memory is used. Or disable the incremental dialyzer in vscode preferences.

@jfayad
Copy link

jfayad commented May 14, 2024

I'm also facing a similar issue on v0.21.1

Here are the behaviors I'm facing:

  1. Every now and then, ElixirLS will crash, I would just restart the extension in VSCode
  2. If I keep my VSCode app open for a while, the RAM gets consumed to a point where no more memory is left (not sure if this is due to the fact that my laptop goes to sleep)

Here are my versions:
Erlang/OTP 26 [erts-14.2.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.16.2 (compiled with Erlang/OTP 26)

vscode: Version : 1.89.1

@probably-not
Copy link

I'm not sure that this is necessarily from the incremental dialyzer... I've disabled the incremental dialyzer on my settings and restarted everything, and I still see the memory usage going up pretty much every time I save... the only time I see the memory usage go down to a normal acceptable level is when I disable the ElixirLS fast Dialyzer, but then I lose all of the dialyzer functionality (even if I enable the incremental dialyzer)

@lukaszsamson
Copy link
Collaborator

@probably-not please provide observer screenshots supporting your claim. So far the ones provided by others strictly show the dialyzer is to blame

@probably-not
Copy link

@lukaszsamson sure, I'll try to dig into this and grab some observer screenshots soon when I'm able to.

But to be clear, I'm not saying that dialyzer isn't to blame - I'm saying that the memory issues weren't solved when I disabled the incremental dialyzer like you've suggested. The memory issues were only solved after fully disabling the ElixirLS Rapid Dialyzer. So I don't believe that this is necessarily related to just the incremental dialyzer, because it seems to only solve itself after fully disabling both Dialyzer options

@probably-not
Copy link

@lukaszsamson Alright, I've dug into this a bit:

With the Incremental Dialyzer Enabled

The behavior that I see from the ETS tables is that every time the Success typings are calculated, it creates the plt_contracts table, but does not delete the old one.

Initial observer screenshot from a freshly loaded project (just one table):
image

Note: this is happening a lot, regardless of code changes, and doesn't seem to be related to crashes at all, or even saves. I can see the "Success typings computed in XXms" printed in the logs every time I go in and out of focus on VSCode. I don't have anything like auto-save turned on, and I'm not hitting any commands, I'm just switching between my Chrome window and my VSCode window and the "Success typings computed in XXms" message gets logged, along with a brand new table.

image

Observer screenshot after seeing these logs (no saves, no code changes, no commands run, just going between windows):
image

With the Incremental Dialyzer Disabled

When incremental dialyzer is enabled, I see in observer that the processes memory usage is lower than when the incremental dialyzer is disabled:

Enabled (73MiB):
image

Disabled (101MiB):
image

However, the process memory tends to flucutate a lot (it's very hard to screen-capture this with observer because of how often it's sampling, but I can see the memory fluctuating up and down in my activity monitor, I'll try to figure out a way to screen record this behavior but I might not be able to for a few days since I'm not at my full workstation), again whenever the Success typings are calculated, which is happening in the same way as I described above - a lot more than it needs to happen.

This seems to be what causes the high memory usage that I'm seeing even with the incremental dialyzer disabled. Because the memory fluctuates every time the Success typings are calculated, and these are calculated whenever the window focus seems to change (which happens a lot when I'm actively working), then the memory spikes up even with only the rapid dialyzer.

Conclusion

It looks like there's a couple of issues in play here. The main issue seems to be that the Success typings are being calculated far more often than necessary, regardless of code changes or saves - this is causing both of the issues, the memory fluctuations when the new incremental dialyzer is turned off, and the table duplications when the new incremental dialyzer is turned on.

@probably-not
Copy link

The "Success typings computed in XXms" originates here, which looks like it's directly related to the Code lens functionality in VS code, which is part of the "Suggest spec" feature that can be enabled and disabed in VSCode.

Disabling this feature has removed the apparent memory and table duplications issue that the new incremental dialyzer has (at the cost of losing the spec suggestions), and still gives me dialyzer warnings when I make a mistake, which seems to be a good temporary fix for now.

@fnicastri
Copy link

@fnicastri you can fire up the observer as explained here to check where this memory is used. Or disable the incremental dialyzer in vscode preferences.

Disabling incremental dialyzer keep the memory down, even after hours (no coding, just leaving the project open)

@lukaszsamson
Copy link
Collaborator

@probably-not Excellent investigation. @fnicastri thanks for confirming. PLT loading turned out to create ETS tables which were never freed. I refactored how PLTs are handled. Now the incremental dialyzer avoids loading them on code lens request. I also resolved a bunch of dialyzer crashes to make it more stable. I believe the excessive memory usage problems are now solved in v0.21.3

@yordis you reported problems with v0.20 so incremental dialyzer was not involved. Did you happen to pinpoint the issue? Is it still present in v0.21.3?

@probably-not
Copy link

Sure, happy to help ✌️ If I understood more about dialyzer internals I would have offered to help even more 😅

I'll update later this week (a bit busy at the moment) and confirm that the behavior has been fixed!

@probably-not
Copy link

@lukaszsamson Did some checking, looks great! I haven't seen the memory issues come back yet, and reducing the recreation of PLTs has also lowered a lot of the CPU overhead as well!

My opinion is that this issue can be closed, but I'm not sure if there are any lingering issues for any others here

@yordis
Copy link
Author

yordis commented May 26, 2024

Did you happen to pinpoint the issue? Is it still present in v0.21.3?

Let me switch back to VS Code and test it again

@fnicastri
Copy link

@lukaszsamson
It seems fine to me now!
Memory stays "low" with Incremental Dialyzer enabled

Thank you!

@yordis
Copy link
Author

yordis commented May 27, 2024

I am gonna close it for now, if I see the issue happening, I would reopen it. Thank y'all for the work! Appreciate!

@yordis yordis closed this as completed May 27, 2024
@lukaszsamson
Copy link
Collaborator

I noticed a similar issue on my machine recently so there may be more cases. I wasn't yet able to reproduce it.

@lukaszsamson lukaszsamson transferred this issue from elixir-lsp/vscode-elixir-ls Jun 12, 2024
@princemaple
Copy link
Contributor

My fan goes crazy for a few seconds every time I save. Even if nothing changed. AFAIK, for me, this only started to occur recently. Not sure if it's related. Some logs attached.

lsp-elixir: INFO: Compile took 1406 milliseconds lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] Updating index... lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 modules need reindexing lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 symbols added to index in 0ms lsp-elixir: INFO: Updating incremental PLT lsp-elixir: INFO: Incremental PLT updated in 12279ms, changed 6 modules, analyzed 24, 0 warnings found lsp-elixir: INFO: Loaded PLT info in 1683ms lsp-elixir: INFO: Dialyzer analysis is up to date lsp-elixir: INFO: Success typings computed in 2141ms lsp-elixir: INFO: Starting build with MIX_ENV: dev MIX_TARGET: host lsp-elixir: LOG: All deps are up to date lsp-elixir: WARNING: warning: unused alias Thread │ 7 │ alias Prac.Chat.{Thread, Message} │ ~ │ └─ lib/prac_web/components/chat_components.ex:7:3

lsp-elixir: INFO: Compile took 1233 milliseconds
lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] Updating index...
lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 modules need reindexing
lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 symbols added to index in 0ms
lsp-elixir: INFO: Updating incremental PLT
lsp-elixir: INFO: Incremental PLT updated in 1128ms, changed 0 modules, analyzed 0, 0 warnings found
lsp-elixir: INFO: Loaded PLT info in 1515ms
lsp-elixir: INFO: Dialyzer analysis is up to date

@lukaszsamson
Copy link
Collaborator

@princemaple 1.5s for build, 2.6s for dialyzer. OTP incremental dialyzer is slower than the old engine

@princemaple
Copy link
Contributor

Interesting: when working on another 10x more complicated project the fan didn't even make a sound.

lsp-elixir: INFO: Starting build with MIX_ENV: dev MIX_TARGET: host lsp-elixir: LOG: All deps are up to date lsp-elixir: LOG: Compiling 19 files (.ex) lsp-elixir: LOG: Generated app app lsp-elixir: INFO: Compile took 2742 milliseconds lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] Updating index... lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 modules need reindexing lsp-elixir: INFO: [ElixirLS WorkspaceSymbols] 0 symbols added to index in 0ms lsp-elixir: INFO: Updating incremental PLT lsp-elixir: INFO: Incremental PLT updated in 6426ms, changed 1 modules, analyzed 1, 1 warnings found lsp-elixir: INFO: Loaded PLT info in 1246ms lsp-elixir: INFO: Dialyzer analysis is up to date lsp-elixir: INFO: Success typings computed in 15ms

I'll try and figure out what's wrong next time I get back to the simpler project.

@RomanMIzulin
Copy link

Seems like when I do "go to definition" to library file, my all CPU cores explodes.
Phoenix, Ash
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Mix 1.17.2 (compiled with Erlang/OTP 26)

@yordis yordis reopened this Aug 6, 2024
@yordis
Copy link
Author

yordis commented Aug 6, 2024

I am reopening for visibility; let me know if you disagree with it

@jkarstens
Copy link

jkarstens commented Aug 11, 2024

My fan is also whirring up a storm every time I save in a mix project. Doesn't happen on a standalone Elixir script, only on an Elixir file in a mix project.
In my System Monitor, I see memory usage for the elixir-ls launch script jump from ~330MB to ~1.1GB and down again for a simple Elixir file save in a mix project (no edits) - is that expected?

What's really strange is that elixir-ls sometimes deletes a normal line of code on save (automatic code deletion stops when I stop elixir-ls). I also saw it insert a space randomly in the word alias.
I think the automatic line deleting/space inserting started happening after I wrote and used a custom function async/1 in my mix project, maybe that caused something?

Using neovim on Linux, elixir 1.17.2-otp-27
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-t
hreads:1] [jit:ns]

Mix 1.17.2 (compiled with Erlang/OTP 27)

@jsermeno
Copy link

jsermeno commented Aug 27, 2024

In my case, I'm able to cause the memory usage to spike very quickly using the debugger in VSCode. To reproduce I can start the debugger with no breakpoints, or step through all breakpoints. It takes ~1 min for the beam.smp process to reach 60 GB of memory. My VSCode launch configuration:

        {
            "type": "mix_task",
            "name": "chat: mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace",
                "--only",
                "run"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}/apps/chat",
            "requireFiles": [
                "${workspaceRoot}/apps/chat/apps/chat/**/test_helper.exs",
                "${workspaceRoot}/apps/chat/apps/chat/**/*_test.exs"
            ],
            "debugInterpretModulesPatterns": ["BmvpWeb*"],
            "exitAfterTaskReturns": false
        }

Add this line "debugAutoInterpretAllModules": false and manually adding all my project files to the "requiredFiles" list solves the issue.

        {
            "type": "mix_task",
            "name": "chat: mix test",
            "request": "launch",
            "task": "test",
            "taskArgs": [
                "--trace",
                "--only",
                "run"
            ],
            "startApps": true,
            "projectDir": "${workspaceRoot}/apps/chat",
            "requireFiles": [
                "${workspaceRoot}/apps/chat/apps/chat/**/test_helper.exs",
                "${workspaceRoot}/apps/chat/apps/chat/**/*_test.exs",
                "${workspaceRoot}/apps/chat/apps/chat/lib/**/*.ex",
            ],
            "debugAutoInterpretAllModules": false,
            "debugInterpretModulesPatterns": ["BmvpWeb*"],
            "exitAfterTaskReturns": false
        }

A bunch of errors pop up with this configuration saying: warning: redefining module ... (current version loaded from .elixir_ls/debug_adapter/build/test/lib.

This seems to point to the problem being from interpreting dependency modules. The issue occurs very quickly while debugging because it interprets all dependency modules in quick succession.

@lukaszsamson
Copy link
Collaborator

@jsermeno debug adapter memory leak is another problem not related to this issue, see some investigation in #1017

I believe you shouldn't be using requireFiles for ex files. This should be sufficient

"debugAutoInterpretAllModules": false,
debugInterpretModulesPatterns": ["BmvpWeb*"],

The issue occurs very quickly while debugging because it interprets all dependency modules in quick succession.

In your current configuration the modules are indeed loaded twice. First time by mix task and second via requireFiles (which calls Code.require_file)

@jsermeno
Copy link

jsermeno commented Aug 28, 2024

@lukaszsamson Thanks for getting back so quickly!

Ah I see, thanks for the link to the correct issue. I didn't understand the purpose of debugInterpretModulesPatterns since I had just found it on a Stack Overflow post. Changing that to my module prefix debugInterpretModulesPatterns": ["MyModulePrefix*"], solved the problem without adding any files to the requiredFiles property.

Referring to that other issue though, I don't think it is Cowboy specific. I've created a minimal reproduction in this repo: https://github.com/jsermeno/elixir_ls_debug_failure. The only dependency I need to recreate this issue in a brand new project is {:stream_data, "~> 1.0", only: [:dev, :test]} and the following code:

  def gen_data() do
    StreamData.list_of(StreamData.fixed_map(%{
      "e" => StreamData.string(:utf8)
    }), min_length: 1, max_length: 1)
  end

  def gen_data_all() do
    gen all fixed_map <- gen_data() do
      fixed_map
    end
  end

  test "greets the world" do
    data = Enum.at(gen_data_all(), 0)
    assert ElixirLsFailure.hello() == :world
  end

I'll open an issue with StreamData as well. However, it seems it's likely not something specific this library since I don't believe Phoenix relies on this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests