Improving Compilation Performance
Optimization techniques for speeding up compilation of large models include scalable compilation, incremental compilation, and memory or disk caching for model compilation artifacts.
Scalable compilation helps reduce compilation time for models that consist of a pattern of repeated components, such as transmission lines or battery packs, by compiling a repeated component once and then reusing these compilation artifacts for other instances of the same component. Scalable compilation improves compilation performance, it does not reduce the simulation time of the model.
Incremental compilation reuses compilation artifacts of reusable components for subsequent compilations, unless the component has been modified between simulation runs. Incremental compilation and memory caching result in improved performance for repeated model simulations and block diagram updates within the same MATLAB® session.
To take advantage of scalable and incremental compilation, you need to designate reusable components and enable component reuse. Memory caching is performed automatically.
Instead of memory caching, you can choose to store the cached compilation artifacts on disk. Disk caching persists between MATLAB sessions and therefore improves the performance of the first compilation of a model in a given session.
Model Settings
Reuse components during compilation | Option to specify whether to enable component reuse for scalable and incremental compilation (Since R2021b) |
Store cached compilation artifacts on disk | Option to specify whether to store cached compilation artifacts on disk or in memory (Since R2024b) |
Enable multithreaded compilation | Option to specify whether to use multithreaded compilation on multicore machine (Since R2023b) |
Topics
Component Reuse
- Enable Component Reuse During Compilation
Workflows, techniques, and examples of speeding up compilation of large models. - Reuse Compilation Artifacts of Individual Simscape Blocks
Speed up compilation by selectively reusing artifacts of individual blocks for scalable compilation. - Reuse Compilation Artifacts of Textual Components
Speed up compilation of models that use complex textual components.
Scalable Compilation
- About Scalable Compilation
General workflow and types of models that can benefit from scalable compilation. - Prepare Your Model for Scalable Compilation
This example shows how to evaluate a model and prepare it for scalable compilation. - Determine Optimal Complexity Level for Reusable Components
Guidelines and considerations for determining the optimal model configuration for scalable compilation.
Other Optimization Techniques
- Disk Caching of Compilation Artifacts
Speed up compilation and simulation of models between sessions. - Multithreaded Compilation
Speed up compilation of models on multicore machines.