How to improve the calculation speed of Matlab by RAMDisk ?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Thank you for concerning this email.
A brief introduction of RAMDisk is cited as follows: A RAMDisk acts as a virtual drive on your system. It allows you to create directories, copy files to and from it, etc.... However, the data is not written onto a hard disk, but remains purely stored into a particular part of the physical RAM memory. Hard disks have mechanical parts that are needed to seek to a particular position on the magnetic storage media and to read/write data. This makes them relative lazy. A RAMDisk does not need to seek, and by this, it can read and write the same data to upon 30-60 times faster than a hard disk !
Considering sb who has enough ram, maybe it is reasonable to use RAMDisk to improve the speed of Matlab. If we need that, maybe there are three options.
1) Install Matlab directly on RAMDisk. Since sometimes the complete installation of Matlab requires more than 5 or 6G, for personal pc with ram less than 8G, it seems unreasonable and also a kind of waste of ram.
2) Install Matlab on HD, and remapped using a "junction" ( with means of , for example , linkd.exe ) to a copy on the RAMDisk.
3) Only put the M-file (program code files) in RAMDisk.
Cautions: No matter which option is selected, the content of the ramdisk must reload automatically at boot time from an image file , or by means of a backup program.
In my case, option 3) only is not enough, almost no change. Then we need to turn to option 2). Since I am not so familiar with the workflow, could anyone kindly teach me which folders I have to linked to RAMDisk to speedup Matlab.
Thank you very much !
0 Kommentare
Antworten (2)
Image Analyst
am 14 Sep. 2013
Replace your hard drives (HDs) with solid state drives (SSDs). That's what everyone does these days. It's really RAM memory, not a hard drive so the terminology everyone uses today is SSD, not RAMDisk, but they're practically the same thing: electronic memory instead of magnetic disk. I'm not sure if SSD memory is as fast as RAM memory but it should be pretty close - a heck of a lot faster than HD memory for certain.
3 Kommentare
Jan
am 14 Sep. 2013
Bearbeitet: Jan
am 14 Sep. 2013
Moving the files from Matlab's root folder on the harddisk to the RAM disk is not an efficient option. The M-files of the toolboxes are read and parsed once only, when they are called the first time. When you avoid to call clear all repeatedly, the parsed M-files are kept in the memory already, so inserting an additional copy in a RAM disk at first cannot improve the total performance.
This means, that none of the 3 options can reduce the total runtime remarkably: The time from starting the computer until the Matlab programs are finished. Even storing the user defines M-files in a RAM disk helps only, if very many files are changed very frequently. During the programming and debugging phase, only a few M-files are touched usually, and in the productive phase a large number of M-file changes can only happen, when these files are created dynamically. But this would be a bad design, when you work with Matlab.
Therefore my conclusion is, that a RAM disk is counter-productive and the memory should be kept free for the operations. In opposite to this, storing the Matlab files on a SSD accelerates the first (and only) reading of the M-files massively.
Notice that the operating system and the hard drive stores the data in RAM caches already. This does not cover the complete Matlab root folder, but all recently written and read files.
3 Kommentare
Jan
am 16 Sep. 2013
I'm not sure what you are asking for. Do you want to improve the runtime of Matlab? Then there are three strategies:
- Buy a faster computer. Possible speedup: factor 2
- Distribute the processing over many cores (Multi-core processor or a cluster). Possible speedup: factor number of cores (very optimistic)
- Improve the code (pre-allocation, smarter data structures, columnwise processing, smaller Integertypes when possible, multi-threading, MEXed bottlenecks, re-using of graphic objects instead or creating new ones, move repeated calculations out of loops, ...). Possible speedup: factor 1000
Xiangrui Li
am 7 Nov. 2013
Here are cases where RAMDISK may be useful for temporary files. Say if I want to read a gz file. The normal way is to gunzip it to a temp file, read it, and delete the temp file. Another case may be what dicomread does for compressed images. It generates a temp jpeg file by fwrite, and read the jpeg by imread to take care of decompression (imread can't read from RAM), and then delete the temp file.
I tried these on RAMDISK under WIN7+Matlab_2013a, but as other posts pointed out, there is no speed benefit. Is this because the disk write is cached to somewhere in hard disk? If so, is there a way to disable it to make it faster?
Thanks.
Xiangrui
Siehe auch
Kategorien
Mehr zu Language Support finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


