Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Does anyone know how to reduce the file size of a MCP sheet or other ways to speed up processing?
I am working on a big calculation package that reads in Excel data (~30000x15) and manipulates it various times (loads of filtering, sorting, assigning submatrices, etc.) that is going on 20-30 pages. Now the file size is almost 18mb and the sheet is moving very slow and takes a while to save. TOL and CTOL are set to defaults, and I am trying the multithreading option. Only working on one sheet at a time.
Are there any methods to speed things up? Maybe purge past data once a step has been made? I don't have much experience with the clear() function, but could this be of use here? Open for suggestions. Thanks!
MCP 8.0, Windows 10 Pro.
Solved! Go to Solution.
Primes slow performance was criticized here quite some times, but as far as I can remember no significant solutions could be offered.
In some cases vectorized operations were said to help speeding up calculation
https://community.ptc.com/t5/Mathcad/Mathcad-Prime-8-is-very-slow-Tips-or-tricks-to-increase-speed/m-p/840078/highlight/true#M203877
and Vladimir once posted links to a few KB articles but I have not looked at them in detail and am not sure if they would be of much help
https://community.ptc.com/t5/Mathcad/Mathcad-prime-8-0-0-0-slow/m-p/838905/highlight/true#M203777
I don't think that file size itself really is an issue. If the size of the saved file should be decreased you may consider deleting \mathcad\result.xml in the file after saving (mcdx files are just renamed zip files containing a certain file and subdir structure). The result.xml is used to be able to display the results of the last calculations after the last saving when the file is loaded (no automatic calculation on start up as we were used in legacy Mathcad). If its not present, Prime will start to (re)calculate the sheet after loading the file, similar to the behaviour of legacy real Mathcad. Deleting result.xml will not help concerning speeding up the handling and calculation of the Prime sheet - it will just decrease the size of the saved file and as I already said, I don't think that thats an issue.
You may try to get rid of the embedded Excel-component and instead read-in the data from an external Excel sheet using READEXCEL. It sure will decrease the file size (but you would have to manage a separate Excel file) but thats not the point. Using READEXCEL does not need and start Excel itself in the background and so will be faster after loading the worksheet and while I had only glanced over the links ValeryN had posted I saw some issues mentioned with embedded Excxel sheets. So I thought it might be worth a try. I won't expect any improvements concerning the subsequent filtering and submatrix manipulations you describe, but who knows ...
Concerning the usage of clear() I guess you are on your own to experiment and give it try. I can't remember that it was ever mentioned that it would affect file size or speed. But we don't know how memory management and garbage collection is implemented internally in Prime, so its a matter of trial an error.
I also found a thread where someone reported that a solve block fails if Multithreading is enabled and would work OK if its turned off (he was not able to post the sheet). Furthermore the user reported that turning off Multithreading speeds up calculation time for him. But that thread was one in the early days of Prime and I guess that Multithreading in the meantime was fixed and improved by PTC. Multithreading sure adds some overhead which costs time, but if the sheet contains independent threads which can be calculated in parallel it sure should speed up overall calc time by using more than one processor core. But again - you have to give it a try.
Good luck!
Primes slow performance was criticized here quite some times, but as far as I can remember no significant solutions could be offered.
In some cases vectorized operations were said to help speeding up calculation
https://community.ptc.com/t5/Mathcad/Mathcad-Prime-8-is-very-slow-Tips-or-tricks-to-increase-speed/m-p/840078/highlight/true#M203877
and Vladimir once posted links to a few KB articles but I have not looked at them in detail and am not sure if they would be of much help
https://community.ptc.com/t5/Mathcad/Mathcad-prime-8-0-0-0-slow/m-p/838905/highlight/true#M203777
I don't think that file size itself really is an issue. If the size of the saved file should be decreased you may consider deleting \mathcad\result.xml in the file after saving (mcdx files are just renamed zip files containing a certain file and subdir structure). The result.xml is used to be able to display the results of the last calculations after the last saving when the file is loaded (no automatic calculation on start up as we were used in legacy Mathcad). If its not present, Prime will start to (re)calculate the sheet after loading the file, similar to the behaviour of legacy real Mathcad. Deleting result.xml will not help concerning speeding up the handling and calculation of the Prime sheet - it will just decrease the size of the saved file and as I already said, I don't think that thats an issue.
You may try to get rid of the embedded Excel-component and instead read-in the data from an external Excel sheet using READEXCEL. It sure will decrease the file size (but you would have to manage a separate Excel file) but thats not the point. Using READEXCEL does not need and start Excel itself in the background and so will be faster after loading the worksheet and while I had only glanced over the links ValeryN had posted I saw some issues mentioned with embedded Excxel sheets. So I thought it might be worth a try. I won't expect any improvements concerning the subsequent filtering and submatrix manipulations you describe, but who knows ...
Concerning the usage of clear() I guess you are on your own to experiment and give it try. I can't remember that it was ever mentioned that it would affect file size or speed. But we don't know how memory management and garbage collection is implemented internally in Prime, so its a matter of trial an error.
I also found a thread where someone reported that a solve block fails if Multithreading is enabled and would work OK if its turned off (he was not able to post the sheet). Furthermore the user reported that turning off Multithreading speeds up calculation time for him. But that thread was one in the early days of Prime and I guess that Multithreading in the meantime was fixed and improved by PTC. Multithreading sure adds some overhead which costs time, but if the sheet contains independent threads which can be calculated in parallel it sure should speed up overall calc time by using more than one processor core. But again - you have to give it a try.
Good luck!
Thank you @Werner_E ! As my MCP sheet was speeding up, my response time slowed ;-).
I am still working through the vectorization process but I have moved certain steps/processes inside program blocks and that seemed to help! Updating more now...
The size of the Prime (.mcdx) file need not be related to the size of the dataset it is processing. It will, however, when embed the dataset into the Prime sheet (as with an embedded excel file). But it should be no problem to take it out, have the Prime file read the data set for processing.
Besides, a Prime file of 18 mb should easily fit in a single bit, as opposed to a file of 18 MB. 😈
Other tip:
With Mathcad it is so that worksheet variables are kept in memory. Note that every variable (scalar, string, vector or matrix) definition, even if you redefine the same variable name (!), on worksheet level takes up the space for that variable.
On the other hand, a variable defined and used in a Mathcad program construct is lost after execution of that program. I suppose that Prime does the same.
Success!
Luc
Thank you @LucMeekes !! Great tip on moving definitions into program constructs. That seemed to help a lot. Now, my file size is down to 7 MB (MB... ;D).