Skip to content

Commit

Permalink
only 2 cores #274
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Blätte authored and Andreas Blätte committed Oct 29, 2023
1 parent 884cc92 commit 842d4a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ decoded.
against as names if possible.
* `subset` for `corpus` and `subset` objects will use integer struc values for
subsetting, if integer values are passed in logical expression.
* Number of cores limited to 2 as required by CRAN Repository Policy.


# polmineR v0.8.8
Expand Down
20 changes: 12 additions & 8 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@
cqp_reset_registry(registry = registry())
}
}

# Limit data.table's usage to 2 threads on CRAN, cp.CRAN Repository Policy:
# "If running a package uses multiple threads/cores it must never use more
# than two simultaneously: the check farm is a shared resource and will
# typically be running many checks simultaneously."
on_cran <- !isTRUE(as.logical(Sys.getenv("NOT_CRAN", "true")))
if (on_cran) setDTthreads(2L)

NULL
}
Expand Down Expand Up @@ -122,7 +115,18 @@

}
}


# Limit data.table's usage to 2 threads on CRAN, cp.CRAN Repository Policy:
# "If running a package uses multiple threads/cores it must never use more
# than two simultaneously: the check farm is a shared resource and will
# typically be running many checks simultaneously."
setDTthreads(if (.Platform$OS.type == "windows") 1L else 2L)

packageStartupMessage(
"polmineR is throttled to use 2 cores as required by CRAN Repository Policy. To get full performance:\n",
"* Use `n_cores <- parallel::detectCores()` to detect the number of cores available on your machine\n",
"* Set number of cores using `options('polmineR.cores' = n_cores - 1)` and `data.table::setDTthreads(n_cores - 1)`"
)
}

.onUnload <- function(libpath){
Expand Down
1 change: 1 addition & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ the underlying issue and checked all plots.
- moved examples into 'donttest'-blocks to avoid long check times
- I call setDTthreads(2L) in zzz.R to limit usage of cores to 2 on CRAN

To convey to users how to get full performance, I introduced a startup message.

## Test environments

Expand Down

0 comments on commit 842d4a6

Please sign in to comment.