MATLAB: Do the locks generated by the MCR take a long time to expire while running many instances of an executable generated using the MATLAB Compiler

ctflockMATLAB CompilerNetwork

I am running many instances of my MATLAB Compiler generated executable, and these processes are launched on different machines. All of them use the same MCR, installed on a shared network resourcel.
When I run about 30 instances, all the processes get the requisite read and write locks from the filesystem on the MCR cache directory, and release them at the end of their lifetime.
However, when I have more than 40 instances of this application running at the same time on different machines, the processes get the locks they require, and generate the desired output. The release of these locks, however, takes a very long time, and, as a result, all these processes are waiting to terminate.

Best Answer

This behavior is typically observed when all the executables try to access the same MCR cache directory.
As a possible workaround, please set the MCR_CACHE_ROOT variable to a local mount location on each machine that will instantiate the MATLAB Compiler generated application. An example is shown below:
export MCR_CACHE_ROOT=/tmp/mcr_cache_root_$USER # local to host
mkdir -p @MCR_CACHE_ROOT