-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runSimulations vs runSimulationBatches #615
Comments
Interesting.. I would have expected 2 and 3 to yield the same time more or less in your scenario. At any rate, 3 really shines when used in a loop or in an algorithm such as PI etc... where you have to perform multiple run For instance, say you would so sthg like this
I would expect all other times to be much faster, even faster than the parallel run |
Thanks @msevestre What is returned if one of the simulations run in |
Also a very good question. Easy to check by setting a parameter such as a solver parameter to something off. I want to understand why #3 is not faster so I am going to check it out and report |
For every failed run, NULL is returned. The list entry with the ID of the
runSettings exists.
Michael Sevestre ***@***.***> schrieb am Mo., 13. Sept. 2021,
21:32:
… Also a very good question. Easy to check by setting a parameter such as a
solver parameter to something off. I want to understand why #3
<#3> is not
faster so I am going to check it out and report
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#615 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGFT7QDIWWF3U36GQNAOCVTUBZGU7ANCNFSM5D6BYFHQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@abdullahhamadeh If I run the scenario 3 three times in a row: [1] "Using runSimulationBatches:" You can see how the simulation overhead for initialization is gone... It's almost too fast for my liking to be hoenst... @PavelBal Did you check that it actually works as expected...? |
@abdelr I am not quite sure why the call takes so long the first time. It looks like the batches are initialized sequentially. not a big deal since it happens only once but it would be interesting to understand why |
@abdelr Found the issue. Creating a report for thius |
Actually, the way to use the batch would be to create only one batch and add three value sets:
|
I also did some profiling and the results are... well, confusing :D Load one simulation, simulate three times with different doses in a loop (Sequential):
2.94 sec Load the simulation three times, and run in parallel using
0.96 sec - amazing speed-up of simulation time, perfect parallelization. However, the comparison is not 100% fair as we do not count the time for loading simulations. Simulation batch with three runs:
2.48 sec - no benefit as compared with the sequential run!!!! Second run of the batch, dose values doubled to make sure the simulations are actually re-run with new values:
0.06 sec !!!! HOW? Seriously, HOW? And yes it produces the correct results, I plotted them. |
The batch solution prepares everything at the beginning. It is currently not preparing in parallel but Michael already solved that. From there on, every call just simulate but do not initialize the simulations since they are already initialized. The first snippet will actually initialize the simulations when you run them. This is why the runSimulationBatches will perform faster the second time, even faster than the runSimulations on the first snippet. I would expect now that the version we have (with the PR fixing the initialization not done in parallel) to perform initially as good as the runSimulations and still, very fast the second time. |
@PavelBal
So in this case, you can see the pure benefit of running in parallel. as to the time for the batch. I am also very surprised by the gain. I have implemented the Batch component myself and I know that we are optimizing a lot. Yet running the simulation in 0.06 sec seems very very surprising. We do not get this kind of speed for the population simulation that is using the exact same concept. It could be that we do lose some time with the UI thread always trying to refresh the progress bar etc... but still..... @PavelBal If you say that the outputs are correct....then maybe we have just a fantastic running engine in R... but I am still suspicious |
sim-batch-test.zip
I've run a script to compare 1) sequential runs of
runSimulation
, 2)runSimulations
, 3)runSimulationBatches
, (attached).I found that 1 and 3 yield very similar simulation times, but there are obvious improvements with 2:
`[1] "Pure sequential run:"
12.92 sec elapsed
[1] "Parallelized using runSimulations:"
5.41 sec elapsed
[1] "Using runSimulationBatches:"
12.65 sec elapsed`
Under what scenarios does
runSimulationBatches
speed up the process?The text was updated successfully, but these errors were encountered: