Parallelization
mdadash supports running Widgets in parallel. It uses Joblib with the default
loky backend to run the parallel jobs as separate processes. A global “Parallel Jobs”
under “Settings > Dashboard Configuration” in the dasboard controls the total number of jobs
that can run in parallel (n_jobs param for joblib.Parallel call).
All the analyses that run in mdadash are CPU-bound and hence a Process-based parallelism is chosen instead of Thread-based parallelism.
IMDReader uses imdclient to connect to a live MD simulation. Because of the use of a network socket within imdclient, this is not serializable by default. mdadash patches IMDReader to remove imdclient from the serialization state since the trajectory is never iterated using imdclient within a parallel job. This makes parallelization possible within mdadash for streaming trajectories.
A Widget class that supports a parallel _run_mode must implement
get_parallel_job() and
apply_parallel_results() methods.
Here is the Widget execution flow when there are parallel Widgets to be run:
As mentioned in the docs for the
get_parallel_job() and
apply_parallel_results() methods, everything
needed by the Widget class (ouputs, updated internal state, etc) must be explicitly returned
back as return values from the parallel job and applied back to the Widget.
Given the choice of Process-based parallelism, there will be serialization and de-serialization
overheads involved when Widgets run in parallel mode. mdadash uses shared memory within the
BufferedTrajectory to keep these overheads to the absolute
minimum. A global “Shared Memory” option under “Settings > Universe Configuration” in the
dashboard controls whether or not to use this feature. This is enabled by default.
Tip
Enabling “Shared Memory” under “Settings > Universe Configuration” will keep serialization and de-serialization overheads to the minimum when running widgets in parallel.
Warning
When running mdadash in docker containers, note that the default shared memory size is limited to 64MB unless explicitly configured for the container. When mdadash fails to allocate the required buffer size in shared memory it falls back to using regular memory.
The list of all the Widgets that can be run in parallel can be found on the Built-in Analysis Widgets page.