Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63fe817

Browse filesBrowse files
committed
toggle use of tbbmalloc_proxy via envvar
1 parent 28d0ced commit 63fe817
Copy full SHA for 63fe817

File tree

Expand file treeCollapse file tree

2 files changed

+25
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-7
lines changed

‎NEWS.md

Copy file name to clipboardExpand all lines: NEWS.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
## RcppParallel 5.1.3 (UNRELEASED)
33

4+
* The `RCPP_PARALLEL_USE_TBBMALLOC_PROXY` environment variable can now be used
5+
to control whether RcppParallel loads the `tbbmalloc_proxy` library on load.
6+
See https://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Automically_Replacing_malloc.html
7+
for more information.
8+
49
## RcppParallel 5.1.2
510

611
* `RcppParallel` gains the `tbbLibraryPath()` function, to be used when attempting

‎R/zzz.R

Copy file name to clipboardExpand all lines: R/zzz.R
+20-7Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11

2-
# NOTE: we intentionally do _not_ load tbbmalloc_proxy as its intended
3-
# use is to replace the default allocator, something that is dangerous
4-
# to do by default (and especially should only be done via e.g. LD_PRELOAD)
5-
.dllInfo <- NULL
6-
.tbbDllInfo <- NULL
7-
.tbbMallocDllInfo <- NULL
2+
# !diagnostics suppress=.dllInfo,.tbbDllInfo,.tbbMallocDllInfo,.tbbMallocProxyDllInfo
3+
4+
# NOTE: we intentionally do _not_ load tbbmalloc_proxy by default, as its
5+
# intended use is to replace the default allocator, something that may be
6+
# dangerous to do by default. in addition, TBB's documentation recommends
7+
# only loading explicitly via e.g. LD_PRELOAD
8+
.dllInfo <- NULL
9+
.tbbDllInfo <- NULL
10+
.tbbMallocDllInfo <- NULL
11+
.tbbMallocProxyDllInfo <- NULL
812

913
loadTbbLibrary <- function(name) {
1014

@@ -27,6 +31,11 @@ loadTbbLibrary <- function(name) {
2731
.tbbDllInfo <<- loadTbbLibrary("tbb")
2832
.tbbMallocDllInfo <<- loadTbbLibrary("tbbmalloc")
2933

34+
# load tbbmalloc_proxy, but only if requested
35+
useTbbMallocProxy <- Sys.getenv("RCPP_PARALLEL_USE_TBBMALLOC_PROXY", unset = "FALSE")
36+
if (useTbbMallocProxy %in% c("TRUE", "True", "true", "1"))
37+
.tbbMallocProxyDllInfo <<- loadTbbLibrary("tbbmalloc_proxy")
38+
3039
# load RcppParallel library if available
3140
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
3241

@@ -38,7 +47,11 @@ loadTbbLibrary <- function(name) {
3847
if (!is.null(.dllInfo))
3948
library.dynam.unload("RcppParallel", libpath)
4049

41-
# unload tbb_malloc if we loaded it
50+
# unload tbbmalloc_proxy if we loaded it
51+
if (!is.null(.tbbMallocProxyDllInfo))
52+
dyn.unload(.tbbMallocProxyDllInfo[["path"]])
53+
54+
# unload tbbmalloc if we loaded it
4255
if (!is.null(.tbbMallocDllInfo))
4356
dyn.unload(.tbbMallocDllInfo[["path"]])
4457

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.