JM

Table of Contents

Summary

Advantages

  • As each process need not live on the same machine, a multiprocessing approach can be practically scaled up to almost any size. This means it is better able to utilise huge amounts of compute via supercomputing clusters (i.e. your local HPC).
  • As each process must use its own memory, race conditions are much rarer. Lack of race conditions eliminates the needs for locks and can improve performance.
  • Each process can use libraries and resources that are not thread-safe in parallel.

Disadvantages

  • Each task must be communicated to each process, including all dependencies such as functions and data. Functions and required data used by each worker must be loaded on every individual process.
  • Multiprocessing implementations usually require external libraries to work effectively.
  • Cannot share memory between nodes; care must be taken to explicitly send and request information between nodes.
  • More resources, particularly memory, are required to support all the individual processes1.
  • As with all parallel approaches, ensuring reproducibility can be very tricky when using multiprocessing.
  • With Julia in particular, due to the JIT compiled runtime, each process must compile all the code required to run their assigned tasks, which is a lot of redundant processing. This can be reduced with efforts in precompilation, but is worth bearing in mind.

Footnotes


  1. In the case of MATLAB, each process can take around 11 to 22GB of memory before any data is loaded. If you have many cores, you can only utilise them if you have enough memory for the additional processes.