Responsive GUI

Hi @Jana_El_Mourad,

Here is a free book in AP1 that you can download to help experiment with threads and timers.

Sincerely,

Eugene

2 Likes

Can you give us a thumbnail explanation of the math you’re having to perform? This will help us suggest the right approach to take. I looked up that method but the theoretical explanation is way, way over my head. :face_with_spiral_eyes:

Thanks, Tim.

Jana, the question is: “Do you need this problem fixed in 30 minutes or 30 days?”

As a long-time production programmer, I used to argue with the computer scientists my firm hired as programmers. The firm needed software fixes that would run tonight - quick and nasty. The computer scientists wanted to write elegant and beautiful software that would run in 1 month’s time or more.

Yes, quick and nasty is evil, but it kept the customers happy, giving us time and money to do the “right” thing.

Thank you for sharing @Eugene_Dakin your help is much appreciated

Hello Eric, Actually, SVD was an example. Im working in general with lengthy algorithms; I have some that may take more than 5 minutes to execute.
If you are interested SVD is divided into 4 main for loops, in each loop there are many nested for loops and mathematical operations (matrix multiplications, normalization, etc.).
We have an input matrix A, and we write it as the product of three matrices, UWV, To find these matrices, we calculate the eigenvalues and eigenvectors


Thank you @Mike_Linacre1 for your suggestion, i will explore it :+1:

Just don’t confuse ‘fix’ with ‘workarounds’ pushing problems to the future. And ‘future’ may be a question of hours, not years. The “it worked in my machine” became a meme because of that. Sometimes all it takes is a slightly faster or slower machine to fire a bad code bug.

Everyone, everywhere, want things fixed ASAP. No one should desire exchanging a known problem by another new one coming from nowhere as firing events where they should not be fired. A bug that could not be noticed today may rise tomorrow
 “from nowhere”. Take an extra hour and avoid bad code. 30 min and 30 days is just too much exaggeration.

2 Likes

OK - that’s a little helpful. I have two suggestions:

First, in your SVD example: if your 4 main For loops are independent (i.e., they don’t share data during operation or and don’t need to be run in any particular sequence), you will get a massive performance increase by splitting them into independent console apps and running them via a Shell. Or, use a Worker setup - it’s the same thing. This will let you use 4 additional CPU cores.

If your loops are interdependent - they share data during operation, or one loop relies on the result of another loop - then setting it up as a Worker/console app will help your main app’s GUI responsiveness but won’t have much impact on performance.

Secondly, matrix math is a very common operation and there are libraries that accelerate it using the CPU’s vector operations. This is (likely) hundreds of times faster than loops. On MacOS, look at Apple’s Accelerate framework; on Windows, it looks like DirextXMath is a good starting point. The work needed to integrate these APIs into Xojo can be gnarly at times but I promise you the performance payoff will be worth it!

1 Like

Thank you @Eric_Williams your help is much appreciated