Skip to content

Commit

Permalink
eliminates 'exitlinger' closes #63
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Sep 20, 2023
1 parent 8f5208b commit 692cb93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mirai
Type: Package
Title: Minimalist Async Evaluation Framework for R
Version: 0.10.0.9003
Version: 0.10.0.9004
Description: Lightweight parallel code execution and distributed computing.
Designed for simplicity, a 'mirai' evaluates an R expression asynchronously,
on local or network resources, resolving automatically upon completion.
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mirai 0.10.0.9003 (development)
# mirai 0.10.0.9004 (development)

* Ephemeral daemons now synchronise with the host process and exit as soon as the completed mirai task is received, without an 'exitlinger' period.
* Argument 'exitlinger' retired at `daemon()` as exits due to specified time/task-outs now occur as soon as possible through synchronisation, without an 'exitlinger' period.
* Optimises scheduling at dispatcher: tasks are no longer assigned to a daemon if it is exiting due to specified time/task-outs.
* Deprecated use of alias `server()` for `daemon()` is retired.
* Requires nanonext >= [0.10.0.9007].
Expand Down
17 changes: 8 additions & 9 deletions R/mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
#' @param timerstart [default 0L] number of completed tasks after which to start
#' the timer for 'idletime' and 'walltime'. 0L implies timers are started
#' upon launch.
#' @param exitlinger [default 1000L] time in milliseconds to linger before
#' exiting due to a timer / task limit, to allow sockets to complete sends
#' currently in progress. The default should be set wider if computations
#' are expected to return very large objects (> GBs).
#' @param tls [default NULL] required for secure TLS connections over 'tls+tcp://'
#' or 'wss://'. \strong{Either} the character path to a file containing
#' X.509 certificate(s) in PEM format, comprising the certificate authority
Expand Down Expand Up @@ -78,8 +74,8 @@
#' @export
#'
daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,
walltime = Inf, timerstart = 0L, exitlinger = 1000L,
output = FALSE, tls = NULL, ..., cleanup = 7L, rs = NULL) {
walltime = Inf, timerstart = 0L, output = FALSE, tls = NULL,
..., cleanup = 7L, rs = NULL) {

sock <- socket(protocol = "rep")
on.exit(close(sock))
Expand Down Expand Up @@ -125,6 +121,7 @@ daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,

if (count >= maxtasks || (count > timerstart && mclock() - start >= walltime)) {
send(ctx, data = data, mode = 3L)
until(cv, .timelimit)
break;
}

Expand All @@ -138,8 +135,6 @@ daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,

}

msleep(exitlinger)

}

#' dot Daemon
Expand Down Expand Up @@ -361,7 +356,11 @@ dispatcher <- function(host, url = NULL, n = NULL, asyncdial = FALSE,
if (is.object(req)) req <- serialize(req, NULL)
send(queue[[i]][["ctx"]], data = req, mode = 2L)
q <- queue[[i]][["daemon"]]
serverfree[q] <- req[1L] != .seven
if (req[1L] == .seven) {
close(attr(servers[[i]], "listener")[[1L]])
} else {
serverfree[q] <- TRUE
}
complete[q] <- complete[q] + 1L
ctx <- .context(sock)
req <- recv_aio_signal(ctx, cv = cv, mode = 8L)
Expand Down
6 changes: 0 additions & 6 deletions man/daemon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 692cb93

Please sign in to comment.