[Rd] R process (and forked children via system2) are limited to 1 core?

Nathaniel Smith njs at pobox.com
Wed Aug 6 23:20:34 CEST 2014


On Wed, Aug 6, 2014 at 6:01 AM, Tom Kraljevic <tomk at 0xdata.com> wrote:
>
> Hi,
>
>
> (Using R 3.1.1 on Ubuntu 12.04.4 LTS)
>
>
> What is the recommended way for R to fork a (non-R) process that is not CPU limited?
> Currently I am using R's system2() call, and this is inheriting the environment of the R process.
>
>
> I notice that (at least on Linux) when I am poking around /proc that the R process itself is setting up cpu limitations for itself (max 1 core).
>
>
> Using strace, I see the following:
>
> (strace output)
> out.20612:sched_setaffinity(0, 128, {100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) = 0
>
>
> And proc shows:
>
> (cat /proc/nnn/status)
> Cpus_allowed:   00000001
> Cpus_allowed_list:      0
>
>
> See that the Cpus_allowed bitmask is a single core.  Normally it's fff...f.

When I run R I see:

Cpus_allowed:    ff
Cpus_allowed_list:    0-7

It's possible (likely?) that the culprit here isn't R but rather some
other library that R is loading. Are you using OpenBLAS? By default
OpenBLAS will set an obnoxious cpu mask, unless you override this
using some obscure build system settings. (There might be a runtime
option for disabling it too, I don't remember.  Note also that this is
just one of several obnoxious things OpenBLAS does unless you override
a bunch of obscure build system defaults -- building OpenBLAS
correctly is highly non-trivial.)

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the R-devel mailing list