Improving performance of Matlab execution called from Java process

7 ビュー (過去 30 日間)
Igor Sulpovar
Igor Sulpovar 2018 年 5 月 22 日
編集済み: Jayaram Theegala 2018 年 5 月 31 日
I am writing a suite of Java processes some of which use Matlab. The performance of this setup is slow and I am trying to figure out how to improve it. I develop Matlab code on Windows but the actual app is on Linux.
  • Matlab had been packaged into the jar with Matlab compiler (mcc) and runs with MCR - version 9.2
  • The application processes 8000 independent points of data, each going through the same Matlab function among other things. The process is multithreaded with each thread processing single piece of data at a time until all are done. Total 10 threads are running.
  • The immediate Matlab function caller process runs on of the 10 threads. Previously I’ve seen statements in the message boards suggesting MCR uses process wide lock when called from Java. In an attempt to mitigate that, I’ve attempted to convert one multithreaded process into multiple single threaded processes intending to run them in parallel. That haven’t provided any noticalbe performance improvements.
  • I’ve ran the application in two profilers - JCM and AppDynamics
  • JCM result suggests (but does not prove) thread contention (Java Monitor Wait) pointing to the method that calls matlab
  • AppDynamics shows most of the execution time is spent inside MWMCR:mclFeval and MWMCR:lockI have set env variable MCR_CACHE_ROOT to a local directory - no noticeable performance improvementsI have ran Matlab code in Matlab GUI profiler and vectorized two loops that resulted in profiler showing great performance gains - 1s instead of 8+s for each call. Wen compiled an built, I saw no noticeable performance improvements of the app. (Note, I’ve ran profiler on Windows, while my app runs and uses McR on Linux)
I am looking for suggestions for the next step. What should I check how should I profile Matlabe and MCR to improve performance?
This code is proprietary to my employer so I can't copy and paste it but I can provide more details, if requested.
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 5 月 22 日
It would be interesting to see how the performance was with MATLAB Production Server, which you could probably obtain a trial for.

サインインしてコメントする。

回答 (1 件)

Jayaram Theegala
Jayaram Theegala 2018 年 5 月 31 日
編集済み: Jayaram Theegala 2018 年 5 月 31 日
Hello Igor,
You are correct about the Process Wide Locking of MCR, and to improve the performance, you can consider using MATLAB Production Server (MPS) as Walter has already suggested. If the function call that you are making from Java takes significant time, the speedup you get through MPS parallelization can outweigh the additional time it takes for network I/O and request handling. For more information about MPS, click on the following URL:
-Jayaram

製品


リリース

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by