When using foreach and doRedis the doRedis workers wait until all jobs have reached the redis server before beginning processing. Is it possible to have them begin before all the preprocessing has finished?
I am using an iterator which is working great - preprocessing happens 'just in time' and the job data begins to hit the server as the iterator runs. I can't seem to take advantage of this behavior, though, because the workers just wait until all jobs have been uploaded.
Example code:
library(foreach)
library(doRedis)
registerDoRedis("worklist", "0.0.0.0")
foreach (var = complex.iter(1:1E6)) %dopar% {
process.function(var)
}
In this example complex.iter
takes a while and there are many elements to iterate over. As such it would be great if workers started running process.function()
before all the preprocessing is finished. Unfortunately they seem to wait until complex.iter
has run on all elements.
I have set .inorder=F
.
Any suggestions as to how to achieve this desired behavior? Thanks.