Skip to content

Use more conservative pool_size #267

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

Merged
merged 11 commits into from
May 31, 2020
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
env:
NOT_CRAN: true
R_LANGSVR_LOG: /tmp/languageserver/log
R_LANGSVR_POOL_SIZE: 1
R_LANGSVR_TEST_FAST: NO
steps:
- uses: actions/checkout@v1
- name: Install apt-get dependencies
Expand Down Expand Up @@ -49,6 +51,8 @@ jobs:
env:
NOT_CRAN: true
R_LANGSVR_LOG: /tmp/languageserver/log
R_LANGSVR_POOL_SIZE: 1
R_LANGSVR_TEST_FAST: NO
steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/setup-r@v1
Expand Down Expand Up @@ -78,6 +82,8 @@ jobs:
env:
NOT_CRAN: true
R_LANGSVR_LOG: C:/tmp/languageserver/log
R_LANGSVR_POOL_SIZE: 1
R_LANGSVR_TEST_FAST: NO
steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/setup-r@v1
Expand All @@ -92,9 +98,7 @@ jobs:
- name: Running Tests
run: |
New-Item -ItemType directory -Path C:/tmp/languageserver
# rcmdcheck is not working very well with the task session
# Rscript -e "rcmdcheck::rcmdcheck(args = c('--as-cran', '--no-manual', '--timings'), error_on = 'error')"
Rscript -e "devtools::test()"
Rscript -e "rcmdcheck::rcmdcheck(args = c('--as-cran', '--no-manual', '--timings'), error_on = 'error')"
- uses: actions/upload-artifact@v1
if: failure()
with:
Expand Down
2 changes: 1 addition & 1 deletion R/languageclient.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LanguageClient <- R6::R6Class("LanguageClient",

finalize = function() {
if (!is.null(self$process)) {
self$process$kill()
self$process$kill_tree()
}
super$finalize()
},
Expand Down
3 changes: 2 additions & 1 deletion R/languageserver.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ LanguageServer <- R6::R6Class("LanguageServer",
self$outputcon <- outputcon

cpus <- parallel::detectCores()
pool_size <- min(max(cpus, 2), 3)
pool_size <- as.integer(
Sys.getenv("R_LANGSVR_POOL_SIZE", min(max(floor(cpus / 2), 1), 3)))
# parse pool
parse_pool <- SessionPool$new(pool_size, "parse")
# diagnostics is slower, so use a seperated pool
Expand Down
3 changes: 2 additions & 1 deletion R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Session <- R6::R6Class("Session",
private$id <- id

private$session <- callr::r_session$new(
callr::r_session_options(system_profile = TRUE, user_profile = TRUE),
callr::r_session_options(
system_profile = TRUE, user_profile = TRUE, supervise = TRUE),
# skip waiting
wait = FALSE
)
Expand Down
14 changes: 9 additions & 5 deletions tests/testthat/helper-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ language_client <- function(working_dir = getwd(), diagnostics = FALSE, capabili
client %>% notify(
"workspace/didChangeConfiguration", list(settings = list(diagnostics = diagnostics)))
withr::defer_parent({
if (Sys.getenv("R_COVR", "") == "true") {
# it is necessary to shutdown the server in covr
# we skip this for other times for speed
# it is sometimes necessary to shutdown the server probably
# we skip this for other times for speed
if (Sys.getenv("R_LANGSVR_TEST_FAST", "YES") == "NO") {
client %>% respond("shutdown", NULL, retry = FALSE)
client$process$wait()
client$process$wait(30)
if (client$process$is_alive()) {
client$process$kill_tree()
fail("server did not shutdown peacefully")
}
} else {
client$stop()
client$process$kill_tree()
}
})
client
Expand Down