Replies: 2 comments 20 replies
-
| Re throttling: I had hoped the example below would write a new file every second, but I see no files being written. library(mirai)
library(nanonext)
f <- function() {
  if (!is.finite(later::next_op_secs())) {
    later::later(
      func = \() writeLines(as.character(Sys.time()), basename(tempfile())),
      delay = 1
    )
  }
}
daemons(n = 2L, url = "ws://127.0.0.1:5700", ext = list(f, expression(f())))
now <- mclock()
while (mclock() - now < 3e4) {
  task <- mirai("task")
  msleep(10)
}
daemons(0L)From the  
 That's probably the reason. But maybe I can live without throttling if the launcher logic is fast enough. The original motivation was that in order to know how many new workers to launch,  | 
Beta Was this translation helpful? Give feedback.
-
| A couple of things: 
 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@shikokuchuo, I finally had a free moment to try the extended R dispatcher you sketched in https://github.com/shikokuchuo/mirai/tree/dispatcher. Really promising stuff! Just writing in to share my initial thoughts and requests.
Data
The
crewlauncher is anR6object. Is there a way to send this object to theextargument along with the function and its call? I tried to ship data in the closure of the function, but in the example below,f_datadoes not go along for the ride.Launching
crewuses information about the current task backlog to decide if it should launch workers, as well as how many workers to launch. I think the extended R dispatcher is a great opportunity to simplify the logic of this. Is there a way to get the number of tasks that have not yet been dispatched? Also, the existingserverfreevector looks useful. Is itFALSEif the server is currently running a task andTRUEotherwise?I ran some simple code to see my options:
Output below:
Throttling
For performance, I would like to avoid calling the
crewlauncher every time the dispatcher wakes up. I was thinking of usinglaterto implement a custom throttling mechanism:laterto schedule thecrewlauncher to run e.g. 0.25 seconds later.latermain loop run thecrewlauncher at the 0.25-second mark.I haven't experimented with this part just yet, but I was wondering if you see any pitfalls at this stage.
Beta Was this translation helpful? Give feedback.
All reactions