Poor performance of a simulation software in Linux relative to Windows

Hi Tim,

Note that while the thread is processed, the state is 0. When the tread finish, the following code is executed. This is code is based on Xojo manual. Is there an alternative code?

Hi Beatrix,

I have no option because I have to process essentially the same code for up to 10 chromosomes, depending on the user input.

Marcelo

Yes, as I demonstrated. With a simple While 
 Wend, you’re burning a lot of cpu cycles. Sleeping will greatly increase performance, because it allocates a lot more cpu to the thread itself.

If there is an example in the Xojo manual, we need to file a bug report against the documentation, because it is dead wrong.

But imagine how the Main Thread is stealing Processing Time from your da Thread, while it’s constantly doing the:

Are you done?
Are you done?
Are you done?
Are you done?
...

Wouldn’t it be possible to let your da Thread do it’s thing and let it call another Process when it’s done?
That way no Processing Time is wasted (in this case).

What does the method have to do with the thread? I have threads that go over 20 or more classes with hundreds of methods.

You don’t really expect us to give recommendations based on a 870 lines Code Snippet? Even if would be posted as Code (see below) there’s no chance we go through all of this to see were you can optimize. :slight_smile:

dim u1, sl, u2, i, j, cc, k, idx1, idx2, sl1, il As integer, s As String, ihg1, ihg2, tGen(), tGen1() As int8, sel1, sel2 As Boolean
reds
if idxs = 0 then
  f1Id = “”
end if
if dComplete then
  if not csIl then
    u1 = (tnofpar*(tnofpar - 1)/2) - 1
  else
    u1 = (tnofspar*(tnofspar - 1)/2) - 1
  end if
else
 ...

@Beatrix_Willius is recommending to break down this code into multiple methods, not only for readability but because it would be MUCH easier for you to see areas in which you “waste” time/processing power. :wink:

BTW: It’s easy to break it down into Methods, using the Xojo Editor Rightclick Menu:

1 Like

Another example. All those:
Bildschirmfoto 2022-09-16 um 13.33.45

could be replaced with a Select Case Statement, like:

Select Case chrnumber
Case Is > 1
...
Case Is > 2
...

This would not only add readability, but also speed thing up a bit, because the Process does not need to check chrnumber over and over again but only once.

The Code that is within your If chrnumber
 EndIf Statements, is a good candidate for a Method. If you could make a Method out of it, maybe ONE arrayU = MethodName(chrnumber) would be all you need instead of all those If’s? :wink:

1 Like

Please don’t take offense (we are really just trying to help), but seeing your code like this I think it would be more effective to restructure it before attempting to figure out what actually performs slower on Linux than on Windows.

Maybe the entire App process under Windows can then be reduced from 1 day to a few hours?

DON’T DO THIS.

If you do, your CPU will spend ALL its time in the code of this loop, and the thread will get nothing.

Do what @Tim_Hare suggested.

1 Like

Which item of documentation suggested this?

I thought the best practice was to have a timer, which executes every so often, and IT checks the state of the thread?
So the thread state may only be checked every second, or 10 seconds, for example.

The select case suggestion is a good start.
The code calls other methods.
Have you tried calling 1000 of those methods and timing them, to see how each method compares between Linux and Windows?

Which piece takes most time?

============

The dimensions in my arrays depends on the user inputs

Going back to the REDIM issue, my suggestion is to initialise the array once at the biggest size it can ever be.
Like building a hotel. It may have 200 rooms, but maybe only 30 of them are occupied.
All you need to know is how many are occupied.
Don’t look in the other ones.

Redim is a method for releasing memory.

Exactly. So it releases and grabs memory over and over again.
Grab it once and leave it alone

Saving on disc in Linux is as fast as saving in Windows.

That doesn’t tell us how long the saving part takes, whether it is fast or slow, or whether it could be speeded up.
1 million saves , if each save takes 1 second, is still 11 days

Baby steps. Obviously, the best approach would be an OOP asych solution, but we have to go one step at a time. If you need to be synch mode, sleep is the best you can do.

2 Likes

Hi Tim,

I will change all occurrences, then.

Marcelo

Hi Tim,

It is probably deprecated. In the reference manual I found

ThreadState As ThreadStates

Indicates the state of the Thread.

This property is read-only.

A Thread can be in one of five states. See Thread for details.

This window method checks the State of the Thread and displays a message in a TextField on the form. The parameter is:

Marcelo

Dear Sascha,

Yours and Beatrix suggestions will speed up the windows software. I will attend yours suggestions. But I am not sure that will make the Windows and Linux versions have the same processing time.

Marcelo

It would be great!

I will change the code in all occurrences.

I think that it is deprecated. In the current reference manual I found

ThreadState As ThreadStates

Indicates the state of the Thread.

This property is read-only.

A Thread can be in one of five states. See Thread for details.

This window method checks the State of the Thread and displays a message in a TextField on the form. The parameter is:

I will test and inform you.