cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Speeding up a Mathcad Prime sheet / reducing file size

Andy_C
11-Garnet

Speeding up a Mathcad Prime sheet / reducing file size

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.

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Andy_C)

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!

View solution in original post

4 REPLIES 4
Werner_E
25-Diamond I
(To:Andy_C)

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!

Andy_C
11-Garnet
(To:Werner_E)

Thank you @Werner_E ! As my MCP sheet was speeding up, my response time slowed ;-).

 

  • Understood about the file size. I had never seen a MCP size get that big so I associated it w/ the sheet speed/lag.
  • For my main data input (the large ~30000x15 set), I am only using the READ-in. But, for intermediate steps, I am using the the Excel-compent to display results.
  • For now, I have turned OFF Multithreading. Not sure it was helping, may have been hurting.

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...

LucMeekes
23-Emerald III
(To:Andy_C)

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).

Announcements

Top Tags