elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.49k stars 196 forks source link

Memory and High CPU Usage #1101

Open yordis opened 6 months ago

yordis commented 6 months ago

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

Troubleshooting

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 ```
fnicastri commented 5 months ago

I have the same problem, make it almost unusable.

lukaszsamson commented 5 months ago

Any way to reproduce this?

vuluu2k commented 5 months ago

it's up high cpu and memory when I saved

fnicastri commented 5 months ago

I get this behavior even with a clean phoenix project

asantare commented 5 months ago

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:

asantare commented 5 months ago

I've found a way to reproduce it:

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 commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

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

fnicastri commented 5 months ago

@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 commented 5 months ago

@fnicastri That's most likely unrelated. For reference https://github.com/elixir-lsp/elixir-ls/issues/1017

fnicastri commented 5 months ago

@lukaszsamson

yep, it was me ;)

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

yordis commented 5 months ago

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 commented 5 months ago

@asantare issue fixed in https://github.com/elixir-lsp/elixir_sense/commit/8ec03beb7bbaa0d53dd33cb68ad98ad945cf9cf5

lukaszsamson commented 5 months ago

@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 commented 5 months ago

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

njwest commented 5 months ago

+1, massive resource usage seemingly after the last update

wsbinette commented 5 months ago

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

mihaiphilip commented 5 months ago

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 commented 5 months ago

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

PragTob commented 5 months ago

Thanks a lot! :green_heart:

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 :sweat_smile:

wsbinette commented 5 months ago

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 commented 5 months ago
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 commented 5 months ago

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

@HarshBalyan please use steps from https://github.com/elixir-lsp/elixir-ls/issues/1101 to diagnose.

xadhoom commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

Screenshot 2024-05-14 at 9 31 44 AM

xadhoom commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

@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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

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

Thank you!

yordis commented 5 months ago

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

lukaszsamson commented 4 months ago

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

princemaple commented 3 months ago

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 commented 3 months ago

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

princemaple commented 3 months ago

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 commented 2 months ago

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 commented 2 months ago

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

jkarstens commented 2 months ago

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)