Runtime and core load discrepancies depending on data handover to future_apply #739
Unanswered
hloefflerwirth
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey all, I try to implement some parallel processing into my R package and encountered an interesting issue.
Setup:
R 4.3 was used on a Linux computer, and R 4.2 on another Windows computer
I use the
futurefunctions, however the same behaviour was also shown by theparallelpackagethere is a global variable
mat, which stores a large data matrix as demonstratorthere are two almost identical functions, which call
future_applyfor some parallelized dummy calculations onmatfunAreceivesmatas function parameterfunBaccessesmatin terms of global variable (not as function parameter)a third test is performed simply calling
future_applyoutside of a functionObservation:
funA(mat)takes about 3 seconds,funB()takes less than 2 secondsfunA(mat)not realy uses multiple cores, whilefunB()produces nicely distributed load on the cores, especially in 'real data calculation'I thought that the problem has something to do with data access and scope.
However, also creating local copies of the data matrix within the functions did not change anything.
Still it is a miracle to me why the computation of
funA(mat)is not distributed across the coresThis example uses
future_apply(), but alsoparApply()from the parallel package shows a similar behaviour.I played around with these scripts for a week and tried a lot of variations of the code. E.g. to set environment of
future_applyandfunAto the global environment, and also the environment offuture_applyto the local environment offunA. But still the problem persists.So, I realy like to understand a bit what is going on there 'under the hood' and eventually make funA perform similar to funB, but still receiving the data in terms of its function parameters.
Thanks for your thoughts and help :)
Beta Was this translation helpful? Give feedback.
All reactions