Comments (2)
I agree the documentation and behavior is confusing.
When run with mc.preschedule=TRUE
(default) and mc.cores=1L
, mclapply()
will actually not fork a separate process:
Line 117 in mclapply():
if (cores < 2L) return(lapply(X = X, FUN = FUN, ...))
i.e. same behavior you noted for pvec()
. However, I guess technically this doesn't go against the documentation, since it says:
a integer giving the maximum allowed number of additional R processes allowed to be run in parallel to the current R process.
So, when mc.cores=1L
, allowed additional processes are either 0 (as with mclapply(mc.preschedule=TRUE)
or 1 (as with mclapply(mc.preschedule=FALSE)
.
But like I said, that is confusing and also inconsistent. It makes no sense to fork one additional process and have the main process simply wait.
The idea of the main process simply waiting I guess is the rational behind using mc.cores=detectCores()
instead of - 1L
. The point isn't so much to define how many simultaneous processes are allowed, but how many processes are allowed to compute at the same time. (Hence the two different behaviors of mclapply(mc.cores=1L)
of one or two simultaneous processes, but only one actually doing anything.)
from wishlist-for-r.
Thanks for the comments @ilarischeinin and for spotting the mcapply(mc.preschedule=TRUE)
case; I've updated my top comment accordingly. To me this indicates that the developer(s) had similar ideas but at some point we ended up with a requirement of mc.cores >= 1
.
I've also fixed a typo in my code suggestion: It should be if (mc.cores == 0 || (isChild() && !isTRUE(mc.allow.recursive)))
and nothing else.
About the number of active versus computing processes: Yes, it's true that the main process shouldn't consume that much of the CPU since it is "just" spawning and polling for results. Having said this, I can imagine that there are obnoxiously strict compute clusters that would kick you out if you ran one process more than you requested (regardless of it's CPU usage). Moreover, this is holds for mclapply()
. If you use for instance mcparallel()
, there is nothing preventing you from running for computations in the main process as well. This can certainly becomes a reality with futures, where a main loop spawns of background processes and collects and post-processes results as they come back in while still polling for results of non-finished processes. This is why I think it is very important that the definition of mc.cores
is very transparent and clear.
from wishlist-for-r.
Related Issues (20)
- Rscript -e EXPR fails to launch if stdin is closed HOT 3
- Suggested performance improvements in R HOT 1
- Separate Build-depends: from Suggests: in DESCRIPTION files HOT 9
- Allow setting breakpoints from debugger
- WISH: `drop` = FALSE by default for `[.data.frame` HOT 9
- Fast check for discreteness
- Make UTF-8 the default encoding for package metadata HOT 2
- WISH/ROBUSTNESS: Mechanism to prevent var <<- value from assigning non-existing 'var' HOT 1
- Consistency: fix matrix subsetting behaviour to be consistent with vectors and data.frames.
- Base R function for length(unique(x))
- WISH: Standardized SystemRequirements HOT 1
- `grDevices::dev.capabilities()` enhancements
- Permit larger seed argument values in set.seed() HOT 1
- Wish: base version of glue::glue() HOT 3
- Add predict method for `stats::kmeans()`
- R CMD check: Option for reporting on writes/updates to tools::R_user_dir() during checks HOT 1
- R CMD check: Option for testing with empty tools::R_user_dir() folders
- Control over `NA` equality in `base::rle()`
- WISH: Make serverSocket(0) useful (+ find a random TCP port that can be listened to) HOT 1
- Task & browser hooks to support implementation of a debug adapter protocol client
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wishlist-for-r.