When is furrr::future_pmap() faster than pmap()?

52 Views Asked by At

I implemented a function that is quite expansive.

start<-Sys.time()
plan(multicore, workers = 4)
grid <- expand.grid(v,x,y,z)
mapping<-pmap(list(grid[,1],grid[,2],grid[,3],grid[,4]),.f=function(v,x,y,z){
  ...
},.progress=TRUE)
plan(sequential)
end <- Sys.time()
end-start

this is faster than the same with future_pmap()

Then I tried to do a simpler function because I read that big dataframes or list that get passed around by the workers makes it slow.

start<-Sys.time()
plan(multicore, workers = 4)
future_pmap(list(grid[,1],grid[,2],grid[,3],grid[,4]),.f=function(v,x,y,z){
  return(sum(v,x,y,z))
})
plan(sequential)
end <- Sys.time()
end-start

I tried different dimensions of grid and the last was

10901000        4

never was future_pmap() faster, rather slower. So did I implement it incorrectly or what can I do?

0

There are 0 best solutions below