23337

future waits for execution on single-core machine

Question:

I have 2 machines with identical versions of Ubuntu (16.04), R (3.4.4) and the future package (1.10.0). I am running the code below, that implements asyncronous programming

tic() library(future) plan(multisession) mehAsync = function(){ future::future({ Sys.sleep(5) return('meh') }) } out = mehAsync() what = then(out,function(value){(value)}) toc()

The expected behaviour is that the execution will end almost instantly, leaving what to be a pending promise. In one machine this happens, the execution happens instantly. However in another machine I have, the execution waits for the mehAsync function to execute, finishing after 5 seconds.

As stated before, both machines are almost identical. The key difference between them is that the slower one is a single core machine. However based on my understanding, the multisession plan shouldn't require multiple cores. Just enough resources to open a new R session which the machine has.

The specific questions here are:

<ul><li>Is my understanding of the expected behaviour wrong and this is normal for a single core machine?</li> <li>What other factors that I am not taking into account could be effecting this behaviour?</li> <li>How can I debug this issue as there are no error/warning messages and can't be replicated by myself and other people in independent machines?</li> </ul>

Note: this question came up when trying to investigate <a href="https://stackoverflow.com/questions/52864035/asynchronous-shiny-programming-setting-up-a-basic-example" rel="nofollow">this other question</a>

Answer1:

The default options for the multisession plan sets the workers parameters to availableCores() in a single core machine. Which means if one does not override the parameters when using plan, the number of cores does matter.

Doing

plan(multisession,workers=2)

solves this issue

Recommend

  • How do I create some kind of table of content in GitHub wiki?
  • Printing ggplots out of list does not work in knitr with rmarkdown
  • Issues incrementing a field in MySQL/PHP with prepared statements
  • YouTube embed showinfo has been deprecated
  • How to debug ajax response?
  • CosmosDB SQL query that matches multiple values in an array
  • How can use the webRTC Javascript API to access the outgoing audio RTP timestamp at the sender and t
  • Django ModelForm with Admin Widgets
  • Session value in Javascript
  • collection-repeat with angular component, what is happening?
  • SVG background image in IE9
  • Hive command line Select query time taken incorrect if its not map reduce job in the background
  • How to link a work load item with a commited change?
  • Integrating Django and .Net applications using Single Sign On (SSO)
  • What are zone turns?
  • Is the Go HTTP handler goroutine expected to exit immediately in this case?
  • Picasso Taking time to load images
  • Hibernate in Glassfish - Ejb3Configuration NoClassDefFoundError
  • Parallel sieve of Eratosthenes - Java Multithreading
  • Javascript unload page condition
  • CKeditor stripping font tags instead of converting to span
  • Cursor in wrong place in contenteditable
  • Issue with routerLink directive
  • Spring integration inbound-gateway Fire an event when queue is empty
  • Cloud Code function running twice
  • Redshift Querying: error xx000 disk full redshift
  • Bash if statement with multiple conditions
  • How to remove a SwiftyJSON element?
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Rails Find when some params will be blank
  • PHP buffered output depending on server setting?
  • Swift: Switch statement fallthrough behavior
  • Functions in global context
  • Is possible to count alias result on mysql
  • Check if a string to interpolate provides expected placeholders
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?