mathworks-ref-arch / matlab-dockerfile

Create a docker container that contains a MATLAB install
Other
317 stars 93 forks source link

Huge execution time difference between first and second test run #67

Closed AnasAGSO closed 1 year ago

AnasAGSO commented 1 year ago

Question/what I want:

is there a caching system that is used by Matlab, if yes how can i export it to be able to reuse it?

The problem:

How to reproduce:

Used toolboxes: MATLAB, Simulink, Simulink_Test, Image_Processing_Toolbox, Computer_Vision_Toolbox, Automated_Driving_Toolbox, Control_System_Toolbox and Model_Predictive_Control_Toolbox

Test model: https://de.mathworks.com/help/driving/ug/automate-testing-for-scenario-variants-of-aeb-system.html

Reproducing process:

  1. In an interactive MATLAB session execute : openExample('autonomous_control/AutomateTestingForScenarioVariantsOfAEBSystemExample')

  2. Upload the content of the folder AutomateTestingForScenarioVariantsOfAEBSystemExample to a git repository

  3. In the container git clone, enter your folder and execute: matlab -batch "addpath(genpath(cd)); testFile = sltest.testmanager.load('AutonomousEmergencyBrakingTests.mldatx');testSuite = getTestSuiteByName(testFile,'Test Scenarios');testCase = getTestCaseByName(testSuite,'scenario_25_AEB_PedestrianTurning_Nearside_10kph');resultObj = run(testCase);sltest.testmanager.report(resultObj,'Report.pdf', Title='Autonomous Emergency Braking', IncludeMATLABFigures=true, IncludeErrorMessages=true, IncludeTestResults=0, LaunchReport=false);exit;"

  4. After 13-15min scenario execution will finish, save the container as a new one

  5. Launch the newly created container

  6. Git clone somewhere else and rerun the test and it will take 13-15min

prabhakk-mw commented 1 year ago

Hi @AnasAGSO

It is possible that you are right. MATLAB is a dynamically compiled language, and it may take longer for it to compile and run code for the first time, caching parts of the previous compilation (internally) for use in subsequent runs.

Unfortunately, there isn't a workflow which will allow you to save these cached artifacts for use in a different session of MATLAB.

Are you able to reproduce this behavior outside of the Docker Image?

I'm guessing you would be, and helping you improve performance with this situation is out of the scope of this forum.

I'd recommend reaching out to MathWorks Technical Support for an in-depth investigation. They may be able to better assist you with tips and tricks to improve performance.

PS: I was able to source this link which has some content which may be relevant to you.