Development Environment | ![]() ![]() |
Reducing Startup Time with Toolbox Path Caching
If you run MATLAB from a network server, you can significantly reduce your startup time by using the MATLAB toolbox path cache. The toolbox path cache stores search path information on all toolbox directories under the MATLAB root directory. During startup, MATLAB obtains this information from the cache rather than by reading it from the remote file system.
The toolbox path cache is used only during the startup of your MATLAB session. It is especially useful if you define your MATLAB search path to include many toolbox directories. It takes considerable time to acquire all of this information by scanning directories in the remote file system. Reading it from a pre-generated cache however, is significantly faster. If you have a short toolbox path, there is less benefit to using the cache, but it does still provide a time savings.
If you run MATLAB on a local disk, where your files are not served from a remote system, then the cache may provide no noticeable reduction in startup time. In this case, you may want to leave the toolbox path cache disabled.
Selecting Toolbox Path Cache Preferences
To generate and enable or disable the toolbox path cache, use MATLAB preferences.
With Enable toolbox cache selected, MATLAB displays summary information during startup, sends notification when it loads the toolbox directories from the cache, and displays a warning if the toolbox path cache cannot be found.
With Enable toolbox cache diagnostics selected, MATLAB displays additional information at startup.
MATLAB also provides warnings whenever a toolbox directory is added to the path from the remote file system at startup rather than from the cache. This occurs if the cache has not been kept up to date with changes in the toolbox directories.
To use this, you need write access to the directory that holds the cache file. The button will be grayed out if you don't have write access.
Generating the Toolbox Path Cache
The toolbox path cache is in a MAT-file in the toolbox/local
directory on the system that serves files for MATLAB. When you first install MATLAB on this system, you or your system administrator needs to generate the cache. (MATLAB does not ship with a prebuilt cache). You also need to regenerate the cache file whenever toolbox directories are added or removed so that the cache does not hold out-dated path information. To do so, select Update Toolbox Cache as described in Selecting Toolbox Path Cache Preferences.
Function Equivalent. To update the cache, type the following in the Command Window.
rehash toolboxcache
Enabling Use of the Cache
When MATLAB is first installed, the toolbox path cache feature is disabled. In order to make use of the cache on a distributed file system:
On a nondistributed system, the system user performs both steps.
To enable toolbox path caching, follow the instructions under Selecting Toolbox Path Cache Preferences.
You can disable the use of this feature either on a user-by-user basis or on a global basis. To disable it on a per-user basis, uncheck Enable toolbox cache in the Preferences dialog box. To disable it on a global basis, remove the file toolbox_cache.mat
from the toolbox/local
directory.
Updating the Cache
If you make changes to your toolbox directories, your toolbox path cache file can become out of date. Depending upon the reason for this, you may or may not receive a warning that your cache needs to be updated. This section explains when you need to update your toolbox path cache and how to avoid problems caused by an out-dated cache file.
Updating Cache Following a Product Install or Update. If you install a new toolbox or an update from The MathWorks, it is likely that the information stored in the toolbox path cache no longer accurately reflects your toolbox directories. As part of the installation process, the MATLAB installer marks the cache as being invalid.
When your cache is marked invalid, MATLAB ceases to use cache during startup, loading path information by accessing the directories through the file system instead. MATLAB issues a message at startup to warn you that your toolbox path cache is out-dated and is being ignored. To resume use of the cache, you need to regenerate it using the procedure described in Generating the Toolbox Path Cache.
Updating Cache Following Changes to Toolbox Directories. If you make changes to the MATLAB toolbox directories (for example, by adding or deleting files), the path information in the toolbox path cache file becomes out of date. When you start up your next MATLAB session, this out-dated path information will be loaded into memory from the cache. MATLAB does not issue a warning when this occurs.
If you choose to make changes that affect the toolbox path, you must regenerate the cache file using the procedure described in Generating the Toolbox Path Cache.
![]() | Adding Startup Options for UNIX Platforms | Quitting MATLAB | ![]() |