REditorSupport / vscode-R

R Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=REditorSupport.r
MIT License
1.08k stars 129 forks source link

Flood of connection errors and many processes spawned #728

Closed D3SL closed 2 years ago

D3SL commented 4 years ago

Sometime in the last two weeks I started getting the error Connection to server is erroring. Shutting down server. in VSCode's output window with varying frequency during coding sessions. Today while during a lag spike I took a look at the task manager and saw about 20 R terminal front-end processes each taking nearly 100mb of ram. When I killed each process I got an error in VSCode like this one:

[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
[Error - 7:41:10 pm] Connection to server is erroring. Shutting down server.
R Language Server (18440) exited with exit code 1

I'm on Windows 10, using the latest versions of VSCode and the LSP extension, R 4.0.2, and languageserver 0.3.6

renkun-ken commented 4 years ago

Would you like to try with the latest development version of languageserver and see if the problem still persists?

D3SL commented 4 years ago

the R package or the vscode extension?

renkun-ken commented 4 years ago

https://github.com/REditorSupport/languageserver

D3SL commented 4 years ago

I've got it installed, it may be a bit before I know if it's working or not given there doesn't seem to be any consistent way to provoke the issue.

D3SL commented 4 years ago

Actually that was faster than I thought. I don't get the constant error messages now but whatever is causing an extreme runaway spawning of processes is even worse than before, I've got something like 3 full double-screens worth of these processes and sometimes they wind up taking up almost all free resources.

image

renkun-ken commented 4 years ago

Looks like it might be caused by the session pool? @randy3k @qinwf any idea why this could happen?

D3SL commented 4 years ago

In case it's relevant I do often have more than one VSCode window open, often with one of them SSHed into a remote machine, and generally just close my laptop to put it to sleep rather than save and shut down everything. Are there any further logs or dumps I can provide, or any test I can run for you?

arnoudplantinga commented 4 years ago

I'm having the same problem, both in Windows and when using SSH to access a Linux server.

renkun-ken commented 4 years ago

@D3SL @arnoudplantinga

Could you share the answers to the following questions?

  1. Does it occur when you do not open a folder in VSCode but instead open a single R file?
  2. Are you working with multiple workspace folders and open many files from different places outside the workspace folder?
  3. Does it still occur if you write R_LANGSVR_POOL_SIZE=0 in your ~/.Renviron so that the session pools are disabled?
D3SL commented 4 years ago
  1. Yes
  2. Not sure what you mean by this, I just use "open folder" in VSCode. This happens whether or not I open a higher level folder and have multiple projects from various subfolders open at the same time or whether I open only one specific project's folder and subfolders. It also happens whether or not I'm SSHed into a remote machine or working locally only.
  3. I just tried that and I still get 2 R For Windows front-end processes and 7 R For Windows terminal front-end the instant I create an R terminal
D3SL commented 3 years ago

Very late update but this appears to still be thing. I opened VSCode momentarily just to try this and instantly had 4 "R for Windows Front-end" processes and 8 "R for Windows Terminal Front-End" processes just from having a single R script open and R session created.

It's unfortunate because unlike the slower object or plot rendering and windows bracketed paste issue this is an actual showstopper, it eventually winds up eating all available ram and then I'm forced to kill the language server's processes.

image

renkun-ken commented 3 years ago

@D3SL Is it still eating all the memory if you put R_LANGSVR_POOL_SIZE=0 in your ~/.Renviron so that the session pools are disabled?

@randy3k I think we need to minimize the session pool if the machine does not meet a certain condition, e.g. at least 8 CPUs and 32GB RAM?

D3SL commented 3 years ago

Assuming it's using the .Renviron in Documents, which path.expand('~') says is my home folder, yes I put that in when you first suggested it last year. On the upside, it seems like those processes are actually cleaned up on closing VSCode now so I don't wind up with 200 of them like before. EDIT: One thing that is different, opening a single file can sometimes open just VSCode without all of the "console window host" and R for Windows/Windows Terminal front-end processes.

I'm not sure if they'll still grow out of control over time, I can go back to VSC instead of RStudio for a few dev sessions and see if it just stays parked at about this level of memory usage.

renkun-ken commented 3 years ago

~/.Renviron in Windows should mean C:\\Users\\user\\Documents\\.Renviron. You could try file.edit("~/.Renviron") in R.

If R_LANGSVR_POOL_SIZE=0 is properly specified, then a vscode instance with a R workspace folder open will only spawn two R processes that are constantly running in background, one for languageserver, and the other for R help server. The languageserver will spawn at most two more child processes as you open or change a document but will terminate once the task is done.

D3SL commented 3 years ago

Yep, that's it alright. It's definitely the language server, disabling that gets rid of all the extra processes and halves memory usage. With only a single folder and ~20 line script open VSC sits at under 500mb total with the language server disabled, about 50mb specifically noted for "R for Windows terminal front-end". Enabling the language server and reloading the window results in memory usage ballooning to a whopping 1.3 gigabytes with many extra processes of each kind.

Disabling all of my other extensions doesn't make a difference.

Language server disabled, or enabled but before opening any R scripts:

image

Language server enabled and a single script open:

image

And in case it helps I turned on diagnostics for the language server, did the same thing, and here's the output with anything private removed:

language server console output (long) ``` R Language Server (16932) started [2021-10-31 13:16:41.182] connection type: tcp at 60768 [2021-10-31 13:16:41.197] connected [2021-10-31 13:16:41.513] received: Content-Length: 4735 [2021-10-31 13:16:41.574] received payload. [2021-10-31 13:16:41.575] handling request: initialize [2021-10-31 13:16:41.575] session: { "system": { "sysname": "Windows", "release": "10 x64", "version": "build 19043", "nodename": "[REDACTED]", "machine": "x86-64", "login": "[REDACTED]", "user": "[REDACTED]", "effective_user": "[REDACTED]" }, "pid": 16468, "wd": "[REDACTED]", "args": ["[REDACTED]\R-4.0.5/bin/x64/Rterm.exe", "--quiet", "--slave", "-e", "languageserver::run(port=60768,debug=TRUE)"], "ver": { "platform": "x86_64-w64-mingw32", "arch": "x86_64", "os": "mingw32", "system": "x86_64, mingw32", "status": "", "major": "4", "minor": "0.5", "year": "2021", "month": "03", "day": "31", "svn rev": "80133", "language": "R", "version.string": "R version 4.0.5 (2021-03-31)", "nickname": "Shake and Throw" }, "locale": "LC_COLLATE=English_World.1252;LC_CTYPE=English_World.1252;LC_MONETARY=English_World.1252;LC_NUMERIC=C;LC_TIME=English_World.1252", "env": { "ALLUSERSPROFILE": "C:\\ProgramData", "APPDATA": "[REDACTED]AppData\\Roaming", "ChocolateyInstall": "C:\\ProgramData\\chocolatey", "ChocolateyLastPathUpdate": "132342617466489227", "CLASSPATH": "[REDACTED]", "CommonProgramFiles": "C:\\Program Files\\Common Files", "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files", "CommonProgramW6432": "C:\\Program Files\\Common Files", "COMPUTERNAME": "[REDACTED]", "ComSpec": "C:\\WINDOWS\\system32\\cmd.exe", "DriverData": "C:\\Windows\\System32\\Drivers\\DriverData", "ELECTRON_RUN_AS_NODE": "1", "ESET_OPTIONS": " ", "FPS_BROWSER_APP_PROFILE_STRING": "Internet Explorer", "FPS_BROWSER_USER_PROFILE_STRING": "Default", "HOME": "[REDACTED]Documents", "HOMEDRIVE": "C:", "HOMEPATH": "\\Users\\[REDACTED]", "LANG": "en_US.UTF-8", "LOCALAPPDATA": "[REDACTED]AppData\\Local", "LOGONSERVER": "\\\\JLM-DC-15-210", "MSYS2_ENV_CONV_EXCL": "R_ARCH", "NUMBER_OF_PROCESSORS": "8", "OneDrive": "[REDACTED][REDACTED]", "OneDriveCommercial": "[REDACTED][REDACTED]", "ORIGINAL_XDG_CURRENT_DESKTOP": "undefined", "OS": "Windows_NT", "PATH": "[REDACTED]\Python38\\Scripts\\;[REDACTED]\Python38\\;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Rtools\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;[REDACTED]\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Pandoc\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\dotnet\\;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\ProgramData\\DockerDesktop\\version-bin;[REDACTED]\Python38\\Scripts\\;[REDACTED]\Python38\\;[REDACTED]AppData\\Local\\Microsoft\\WindowsApps;c:\\xampp\\php;[REDACTED]AppData\\Local\\Programs\\Microsoft VS Code\\bin;[REDACTED]AppData\\Roaming\\npm;", "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW", "PROCESSOR_ARCHITECTURE": "AMD64", "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 142 Stepping 10, GenuineIntel", "PROCESSOR_LEVEL": "6", "PROCESSOR_REVISION": "8e0a", "ProgramData": "C:\\ProgramData", "ProgramFiles": "C:\\Program Files", "ProgramFiles(x86)": "C:\\Program Files (x86)", "ProgramW6432": "C:\\Program Files", "PROMPT": "$P$G", "PSModulePath": "C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules", "PUBLIC": "C:\\Users\\Public", "R_ARCH": "/x64", "R_COMPILED_BY": "gcc 8.3.0", "R_HOME": "[REDACTED]/R/R-4.0.5", "R_LIBS_USER": "[REDACTED]Documents/R/win-library/4.0", "R_USER": "[REDACTED]Documents", "RTOOLS40_HOME": "C:\\rtools40", "SESSIONNAME": "Console", "SystemDrive": "C:", "SystemRoot": "C:\\WINDOWS", "TEMP": "[REDACTED]AppData\\Local\\Temp", "TERM_PROGRAM": "vscode", "TMP": "[REDACTED]AppData\\Local\\Temp", "USERDNSDOMAIN": "XCONNECT.CO.IL", "USERDOMAIN": "XCONNECT", "USERDOMAIN_ROAMINGPROFILE": "XCONNECT", "USERNAME": "[REDACTED]", "USERPROFILE": "[REDACTED]", "VSCODE_AMD_ENTRYPOINT": "vs/workbench/services/extensions/node/extensionHostProcess", "VSCODE_CODE_CACHE_PATH": "[REDACTED]AppData\\Roaming\\Code\\CachedData\\6cba118ac49a1b88332f312a8f67186f7f3c1643", "VSCODE_CWD": "[REDACTED]AppData\\Local\\Programs\\Microsoft VS Code", "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true", "VSCODE_IPC_HOOK": "\\\\.\\pipe\\91f72120522b959b3db4cadd19743a22-1.61.2-main-sock", "VSCODE_IPC_HOOK_EXTHOST": "\\\\.\\pipe\\vscode-ipc-da2d01f9-144a-4668-a82a-aad2cb99deb8-sock", "VSCODE_LOG_NATIVE": "false", "VSCODE_LOG_STACK": "false", "VSCODE_NLS_CONFIG": "{\"locale\":\"en-gb\",\"availableLanguages\":{},\"_languagePackSupport\":true}", "VSCODE_PID": "3300", "VSCODE_PIPE_LOGGING": "true", "VSCODE_VERBOSE_LOGGING": "true", "windir": "C:\\WINDOWS", "ZES_ENABLE_SYSMAN": "1" }, "namespaces": { "Rcpp": "1.0.7", "grDevices": "4.0.5", "languageserver": "0.3.11", "ps": "1.6.0", "later": "1.2.0", "R6": "2.5.0", "jsonlite": "1.7.2", "DBI": "1.1.1", "datasets": "4.0.5", "collections": "0.3.5", "rlang": "0.4.11", "stringi": "1.7.3", "utils": "4.0.5", "callr": "3.7.0", "xml2": "1.3.2", "graphics": "4.0.5", "base": "4.0.5", "data.tree": "1.0.0", "tools": "4.0.5", "parallel": "4.0.5", "compiler": "4.0.5", "processx": "3.5.2", "stats": "4.0.5", "pool": "0.1.6", "methods": "4.0.5" }, "search": [".GlobalEnv", "package:stats", "package:graphics", "package:grDevices", "package:utils", "package:datasets", "package:methods", "Autoloads", "package:base"] } [2021-10-31 13:16:41.612] initialization config: { "processId": 3728, "clientInfo": { "name": "Visual Studio Code", "version": "1.61.2" }, "locale": "en-gb", "rootPath": "[REDACTED]", "rootUri": "file:///[REDACTED]", "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional", "normalizesLineEndings": true, "changeAnnotationSupport": { "groupsOnLabel": true } }, "didChangeConfiguration": { "dynamicRegistration": true }, "didChangeWatchedFiles": { "dynamicRegistration": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "tagSupport": { "valueSet": [ 1 ] } }, "codeLens": { "refreshSupport": true }, "executeCommand": { "dynamicRegistration": true }, "configuration": true, "workspaceFolders": true, "semanticTokens": { "refreshSupport": true }, "fileOperations": { "dynamicRegistration": true, "didCreate": true, "didRename": true, "didDelete": true, "willCreate": true, "willRename": true, "willDelete": true } }, "textDocument": { "publishDiagnostics": { "relatedInformation": true, "versionSupport": false, "tagSupport": { "valueSet": [ 1, 2 ] }, "codeDescriptionSupport": true, "dataSupport": true }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "insertReplaceSupport": true, "resolveSupport": { "properties": [ "documentation", "detail", "additionalTextEdits" ] }, "insertTextModeSupport": { "valueSet": [ 1, 2 ] } }, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ], "parameterInformation": { "labelOffsetSupport": true }, "activeParameterSupport": true }, "contextSupport": true }, "definition": { "dynamicRegistration": true, "linkSupport": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "labelSupport": true }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "disabledSupport": true, "dataSupport": true, "resolveSupport": { "properties": [ "edit" ] }, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } }, "honorsChangeAnnotations": false }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true, "prepareSupportDefaultBehavior": 1, "honorsChangeAnnotations": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "typeDefinition": { "dynamicRegistration": true, "linkSupport": true }, "implementation": { "dynamicRegistration": true, "linkSupport": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true }, "declaration": { "dynamicRegistration": true, "linkSupport": true }, "selectionRange": { "dynamicRegistration": true }, "callHierarchy": { "dynamicRegistration": true }, "semanticTokens": { "dynamicRegistration": true, "tokenTypes": [ "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator" ], "tokenModifiers": [ "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" ], "formats": [ "relative" ], "requests": { "range": true, "full": { "delta": true } }, "multilineTokenSupport": false, "overlappingTokenSupport": false }, "linkedEditingRange": { "dynamicRegistration": true } }, "window": { "showMessage": { "messageActionItem": { "additionalPropertiesSupport": true } }, "showDocument": { "support": true }, "workDoneProgress": true }, "general": { "regularExpressions": { "engine": "ECMAScript", "version": "ES2020" }, "markdown": { "parser": "marked", "version": "1.1.0" } } }, "trace": "off", "workspaceFolders": [ { "uri": "file:///[REDACTED]", "name": "[REDACTED]" } ] } [2021-10-31 13:16:42.398] deliver: ["Response", "Message", "R6"] [2021-10-31 13:16:42.615] received: Content-Length: 52 [2021-10-31 13:16:42.632] received payload. [2021-10-31 13:16:42.632] handling notification: initialized [2021-10-31 13:16:42.632] on_initialized [2021-10-31 13:16:42.633] received: Content-Length: 184 [2021-10-31 13:16:42.647] received payload. [2021-10-31 13:16:42.647] handling notification: workspace/didChangeConfiguration [2021-10-31 13:16:42.647] settings { "enabled": true, "args": [], "debug": true, "diagnostics": true, "lang": "", "use_stdio": false } [2021-10-31 13:16:42.649] received: Content-Length: 1316 [2021-10-31 13:16:42.663] received payload. [2021-10-31 13:16:42.663] handling notification: textDocument/didOpen [2021-10-31 13:16:42.664] did open: { "uri": "file:///[REDACTED].R", "version": 1 } [2021-10-31 13:16:42.710] diagnostics session acquired session_id = 1 remain pool size = 2 [2021-10-31 13:16:42.711] diagnostics session ready 1 2021-10-31 13:16:42 [2021-10-31 13:16:42.715] parse session acquired session_id = 1 remain pool size = 2 [2021-10-31 13:16:42.715] parse session ready 1 2021-10-31 13:16:42 [2021-10-31 13:16:42.718] received: Content-Length: 186 [2021-10-31 13:16:42.742] received payload. [2021-10-31 13:16:42.742] handling request: textDocument/documentSymbol [2021-10-31 13:16:42.762] received: Content-Length: 184 [2021-10-31 13:16:42.774] received payload. [2021-10-31 13:16:42.774] handling request: textDocument/documentLink [2021-10-31 13:16:42.777] received: Content-Length: 185 [2021-10-31 13:16:42.790] received payload. [2021-10-31 13:16:42.790] handling request: textDocument/documentColor [2021-10-31 13:16:42.792] received: Content-Length: 184 [2021-10-31 13:16:42.806] received payload. [2021-10-31 13:16:42.806] handling request: textDocument/foldingRange [2021-10-31 13:16:42.814] parse session released session_id = 1 remain pool size = 3 [2021-10-31 13:16:42.815] parse_callback called: { "uri": "file:///[REDACTED].R", "version": 1 } [2021-10-31 13:16:42.819] document definitions found: 1 [2021-10-31 13:16:42.822] deliver: ["Response", "Message", "R6"] [2021-10-31 13:16:42.905] deliver: ["Response", "Message", "R6"] [2021-10-31 13:16:42.913] deliver: ["Response", "Message", "R6"] [2021-10-31 13:16:42.918] deliver: ["Response", "Message", "R6"] [2021-10-31 13:16:42.919] parse task timing: 0.209367990493774 file:///[REDACTED].R [2021-10-31 13:16:43.592] diagnostics session released session_id = 1 remain pool size = 3 [2021-10-31 13:16:43.592] diagnostics_callback called: { "uri": "file:///[REDACTED].R", "version": 1, "diagnostics": [ { "range": { "start": { "line": 12, "character": 0 }, "end": { "line": 12, "character": 9 } }, "severity": 3, "source": "object_name_linter", "message": "Variable and function name style should be snake_case." }, { "range": { "start": { "line": 12, "character": 8 }, "end": { "line": 12, "character": 12 } }, "severity": 3, "source": "infix_spaces_linter", "message": "Put spaces around all infix operators." }, { "range": { "start": { "line": 12, "character": 25 }, "end": { "line": 12, "character": 28 } }, "severity": 3, "source": "infix_spaces_linter", "message": "Put spaces around all infix operators." }, { "range": { "start": { "line": 12, "character": 36 }, "end": { "line": 12, "character": 39 } }, "severity": 3, "source": "infix_spaces_linter", "message": "Put spaces around all infix operators." }, { "range": { "start": { "line": 12, "character": 63 }, "end": { "line": 12, "character": 66 } }, "severity": 3, "source": "infix_spaces_linter", "message": "Put spaces around all infix operators." }, { "range": { "start": { "line": 18, "character": 97 }, "end": { "line": 18, "character": 98 } }, "severity": 3, "source": "trailing_whitespace_linter", "message": "Trailing whitespace is superfluous." }, { "range": { "start": { "line": 21, "character": 7 }, "end": { "line": 21, "character": 10 } }, "severity": 3, "source": "infix_spaces_linter", "message": "Put spaces around all infix operators." } ] } [2021-10-31 13:16:43.603] deliver: ["Notification", "Message", "R6"] [2021-10-31 13:16:43.603] method: textDocument/publishDiagnostics [2021-10-31 13:16:43.612] diagnostics task timing: 0.902730941772461 file:///[REDACTED].R [2021-10-31 13:16:45.515] resolve_callback called: { "uri": "file:///[REDACTED].R", "version": 1 } [2021-10-31 13:16:46.311] ns: Namespace: ggplot2 [2021-10-31 13:16:46.329] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2"] [2021-10-31 13:16:46.349] ns: Namespace: tibble [2021-10-31 13:16:46.350] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble"] [2021-10-31 13:16:46.397] ns: Namespace: tidyr [2021-10-31 13:16:46.398] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr"] [2021-10-31 13:16:46.534] ns: Namespace: readr [2021-10-31 13:16:46.535] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr", "readr"] [2021-10-31 13:16:46.553] ns: Namespace: purrr [2021-10-31 13:16:46.553] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr", "readr", "purrr"] [2021-10-31 13:16:46.627] ns: Namespace: dplyr [2021-10-31 13:16:46.628] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr", "readr", "purrr", "dplyr"] [2021-10-31 13:16:46.645] ns: Namespace: stringr [2021-10-31 13:16:46.645] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr", "readr", "purrr", "dplyr", "stringr"] [2021-10-31 13:16:46.657] ns: Namespace: forcats [2021-10-31 13:16:46.657] loaded_packages: ["base", "methods", "datasets", "utils", "grDevices", "graphics", "stats", "tidyverse", "data.table", "RMariaDB", "DBI", "pool", "lubridate", "magrittr", "here", "timevis", "htmlwidgets", "ggplot2", "tibble", "tidyr", "readr", "purrr", "dplyr", "stringr", "forcats"] [2021-10-31 13:16:46.666] resolve task timing: 3.84766507148743 file:///[REDACTED].R ```
renkun-ken commented 3 years ago

@D3SL In your languageserver log, I don't find R_LANGSVR_POOL_SIZE=0 in the env. Looks like it does not take effect?

D3SL commented 3 years ago

It's definitely there, I even used file.edit("~/.Renviron") to doublecheck I had the right file in the right place. Could this be a leftover from a very old initial setup or caused by something else somewhere else?

randy3k commented 3 years ago

@randy3k I think we need to minimize the session pool if the machine does not meet a certain condition, e.g. at least 8 CPUs and 32GB RAM?

I think it is reasonable. On top of it, with the default settings, we always create 6 worker R sessions (3 for linting and 3 for parsing). Except in the initialization step, only one worker is running a task and the others are idle at most of the time,. I wonder if we could close some sessions after the initialization step.

D3SL commented 3 years ago

So I'm probably showing my ignorance here asking this, but why doesn't RStudio have this same level of memory usage? It does linting, code completion, and so on as well but the equivalent session to the screenshots I provided here used maybe 600mb as opposed to 1.3-1.5gb.

Yunuuuu commented 2 years ago

Likewise, I have posted this in https://github.com/REditorSupport/vscode-R/issues/735, which is similar to this thread, but I don't know whether the both are the same. It seems my problem is more likely to be related to this thread. vscode-r never terminate the R front-end, so when we restart vscode multiple times, the R for Windows front-end accumulates gradually.

My running environment:

  1. when I seted R_LANGSVR_POOL_SIZE = 0 in my ~/.Renviron and opened a vscode instance (never opened any files), then quit vscode, these process remained runing: image

  2. when I seted R_LANGSVR_POOL_SIZE = 1 in my ~/.Renviron and opened a vscode instance (never opened any files), then quit vscode, these process remained runing: image

  3. when I reopen vscode several times, the process R for Windows front-end in vscode will accumulate: image

This shouldn't be caused by radian, I have run radian alone with R in windows cmd.exe, which didn't present above results.

Yunuuuu commented 2 years ago

This may not be the problem of language server, I think it's the responsibility of vscode-r extension, which created this sub-process, to kill this process when exit?

renkun-ken commented 2 years ago

918 aims to close all spawned processes on dispose. It works as expected as we tested it in Windows, macOS and linux. Looks like in these cases it does not work for some reason in Windows.

Let me see if I can reproduce it in a Windows environment first.

Yunuuuu commented 2 years ago

Thanks for your reply @renkun-ken. Are there any procedures or tests I can help?

I’m not familiar with the vscode extension but just can write some r code.

albertosantini commented 2 years ago

Resolved with https://github.com/REditorSupport/vscode-R/pull/941

D3SL commented 2 years ago

After giving this a bit of use it looks like this is resolved for me too. A reasonable number of processes are spawned up front and they actually close on their own now. Being able to use VSCode instead of RStudio is a big quality of life improvement, to say nothing of the competition to the RStudio monopoly being vital for the R ecosystem's health.

D3SL commented 2 years ago

Unfortunately I spoke too soon, it looks like I'm either still having this issue or it's recurred. I noticed VSCode chugging today and found out ~70% of my ram was being used up by the language server processes. Unticking LSP in settings seems to fix it.

image

Yunuuuu commented 2 years ago

Hi, Maybe you can try to set environment variable R_LANGSVR_POOL_SIZE in your ~/.Renviron to limit the languageserver process, as indicated by renkun-ken.

~/.Renviron in Windows should mean C:\\Users\\user\\Documents\\.Renviron. You could try file.edit("~/.Renviron") in R.

If R_LANGSVR_POOL_SIZE=0 is properly specified, then a vscode instance with a R workspace folder open will only spawn two R processes that are constantly running in background, one for languageserver, and the other for R help server. The languageserver will spawn at most two more child processes as you open or change a document but will terminate once the task is done.

D3SL commented 2 years ago

As noted in this comment I've tried that without success unfortunately.

Hi, Maybe you can try to set environment variable R_LANGSVR_POOL_SIZE in your ~/.Renviron to limit the languageserver process, as indicated by renkun-ken.

~/.Renviron in Windows should mean C:\\Users\\user\\Documents\\.Renviron. You could try file.edit("~/.Renviron") in R. If R_LANGSVR_POOL_SIZE=0 is properly specified, then a vscode instance with a R workspace folder open will only spawn two R processes that are constantly running in background, one for languageserver, and the other for R help server. The languageserver will spawn at most two more child processes as you open or change a document but will terminate once the task is done.