Skip to content

DESIGN: Should multisession workers inherits .libPaths() from parent R session? #435

Closed

Description

@HenrikBengtsson

This originates from #219, which has become quite long and added several manually solutions to the more precise question raised here: Should multisession workers inherit .libPaths() from parent R session?

Currently, if the main R session modifies the library paths, e.g.

> .libPaths()
[1] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"   
[2] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"

> .libPaths(c(tempdir(), .libPaths())

> .libPaths()
[1] "/tmp/hb/RtmpwLKdrG"
[2] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"   
[3] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"

then we have to do:

> plan(multisession, workers = 2L, rscript_libs = .libPaths())

for the multisession workers to see the same settings;

> libs <- value(future(.libPaths()))
> libs
[1] "/tmp/hb/RtmpwLKdrG"
[2] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"   
[3] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"

The question here is whether or not rscript_libs = .libPaths() should be the default. One downside for it not being the default, is that it is up to the end-user to know that they should use plan(multisession, rscript_libs = .libPaths()) and not just plan(multisession). In contrast, they don't have to think about that when using plan(multicore) - it'll just work. This speaks for making rscript_libs = .libPaths() the new default for multisession futures.

I cannot come up with a good reason for not changing the default. I guess, local workers should inherit .libPaths() from the parent R process if they run a compatible version of R. For instance, it should definitely not use the same library paths if the main R session runs R 4.0.3 and the workers runs R 3.6.3. Depending on how R was built (compiler flags etc), we might also have incompatibility between different R 4.0.3 versions, which suggests we should only pass down .libPaths() if we run the exact same R installation (which is the default). Thus, we need to make sure this new default takes into account various corner cases like these. The easiest is probably to condition it on argument rscript not being specified.

cc/ @jcheng5, @aronatkins, @markusdumke

Activity

  1. added this to the Next release milestone on Oct 21, 2020
  2. added
    Backend API
    on Oct 22, 2020
  3. HenrikBengtsson commented on Oct 24, 2020

    @HenrikBengtsson
    CollaboratorAuthor

    Next release will have:

    • Now multisession workers inherit the package library path from the main R session when they are created, that is, when calling plan(multisession). To avoid this, use plan(multisession, rscript_libs = NULL), which is an argument passed down to makeClusterPSOCK(). With this update, 'sequential', 'multisession', and 'multicore' futures see the exact same library path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backend APIenhancementhelp wantedpkg/parallelly

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions