Skip to content

Commit

Permalink
faster bitwise ops using raw vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Aug 17, 2023
1 parent c7e90a6 commit 2fb8985
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 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.9.1.9006
Version: 0.9.1.9007
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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mirai 0.9.1.9006 (development)
# mirai 0.9.1.9007 (development)

* Previously deprecated function `server()` is removed in favour of `daemon()`.
* Dispatcher enhancements and fixes:
Expand Down
15 changes: 8 additions & 7 deletions R/mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,
cv <- cv()
pipe_notify(sock, cv = cv, add = FALSE, remove = TRUE, flag = TRUE)
dial_and_sync_socket(sock = sock, url = url, asyncdial = asyncdial, tls = tls)
op <- options()
se <- search()
count <- 0L
if (idletime > walltime) idletime <- walltime else if (idletime == Inf) idletime <- NULL

if (idletime > walltime) idletime <- walltime else if (idletime == Inf) idletime <- NULL
clr <- as.raw(cleanup)
if (!output) {
devnull <- file(nullfile(), open = "w", blocking = FALSE)
sink(file = devnull)
Expand All @@ -98,6 +96,9 @@ daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,
close(devnull)
}, add = TRUE)
}
op <- options()
se <- search()
count <- 0L
start <- mclock()
while (count < maxtasks && mclock() - start < walltime) {

Expand All @@ -117,8 +118,8 @@ daemon <- function(url, asyncdial = FALSE, maxtasks = Inf, idletime = Inf,
send(ctx, data = data, mode = 1L)

if (cleanup %% 2L) rm(list = names(.GlobalEnv), envir = .GlobalEnv)
if (bitwAnd(cleanup, 2L)) lapply((new <- search())[!new %in% se], detach, unload = TRUE, character.only = TRUE)
if (bitwAnd(cleanup, 4L)) options(op)
if (clr & as.raw(2L)) lapply((new <- search())[!new %in% se], detach, unload = TRUE, character.only = TRUE)
if (clr & as.raw(4L)) options(op)
if (cleanup >= 8L) gc(verbose = FALSE)
if (count < timerstart) start <- mclock()
count <- count + 1L
Expand Down Expand Up @@ -1265,7 +1266,7 @@ parse_dots <- function(...)
dots <- list(...)
dnames <- names(dots)
dots <- strcat(",", paste(dnames, dots, sep = "=", collapse = ","))
"output" %in% dnames && return(`class<-`(dots, .urlscheme))
"output" %in% dnames && return(`class<-`(dots, "output"))
dots
}

Expand Down

0 comments on commit 2fb8985

Please sign in to comment.