Multithreading

User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

How many records you have on the DBF ?
About 75000 records.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Multithreading

Post by Antonio Linares »

Enrico,

I created a 80.000 records DBF (using dbcre8.exe) and tested it with Harbour:

ST: 0,299 secs

MT: 0,345 secs

You are right, MT apps are slower :-(

I am reporting it to the Harbour dev group:
https://groups.google.com/forum/?fromgr ... Ap9qFn9gSs
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Multithreading

Post by anserkk »

StefanHaupt wrote:Enrico,

just to understand, what could be the advantages using MT instead of ST ? What functions could be put in threads ?

Im my understanding a database application is a single thread application with single tasks, e.g. browsing a dbf or searching in a dbf. What can be done, to get simultaneous tasks ?

Stefan
It may be good to have your program to check in the background via a thread for an updated version of your exe on some servers, that too without delaying/pausing/interfering the work of your user on the application. If an updated version is available then it would show a popup message that a new version of the app is available, else nothing happens, the user continues with his work.

Without a thread, the same can be done when the user starts the app, the program will do a check on some server for an updated version and then inform the user about the updated version. But the problem here, is that, the user will have to wait until the checking process is completed. In other words the user's activity is paused for some time and he will have to wait.

There are many other possibilities of using multi threading in your application.

Regards
Anser
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

I created a 80.000 records DBF (using dbcre8.exe) and tested it with Harbour:

ST: 0,299 secs

MT: 0,345 secs

You are right, MT apps are slower :-(

I am reporting it to the Harbour dev group:
https://groups.google.com/forum/?fromgr ... Ap9qFn9gSs
Thank you, Master!

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Multithreading

Post by Antonio Linares »

Enrico,

Mindaugas just answered. his explanation sounds logical, but nobody would want to slow down his app...
regards, saludos

Antonio Linares
www.fivetechsoft.com
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Re: Multithreading

Post by hmpaquito »

Hi all,

Well, I think that (x)harbour applications are super fast. So if the multithreading makes them lose a little speed to my unimportant. The multithreading can bring many good features to our applications.

My two (euro) cents.
User avatar
sambomb
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil
Contact:

Re: Multithreading

Post by sambomb »

Some good uses for MT exe:
Index multiple files simultaneously.
Open non modal dialogs in different threads.
Run long tasks with multiple theads, 1 just for the dialog management and as many as possible for the other tasks.

Obviously, MT exe only will be faster in functions that use multiple threads in multi nuclear processors.
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

Mindaugas just answered. his explanation sounds logical, but nobody would want to slow down his app...
Thank you. :-(

I give up with multithreading. xHarbour's background tasks are much more efficient, despite what Harbour developers can say...

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Multithreading

Post by Antonio Linares »

Enrico,

Have you checked, when you use a background task, if the app speed decrease ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

Have you checked, when you use a background task, if the app speed decrease ?
Yes. Of course, it depends on what the background task is doing. If it is activated but is doing nothing (ie. is executing an empty codeblock) then the app speed doesn't decrease.

EMG
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: Multithreading

Post by Patrizio »

Enrico, Antonio: a test of that kind don't make sense in MT.

Try to make multiple scans of the same dbf file: one after the other in ST, parallel to each other in MT.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Patrizio,
Patrizio wrote:Enrico, Antonio: a test of that kind don't make sense in MT.
The sense is that my application will slow down if I only link the MT libs in. Unacceptable for me.

EMG
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: Multithreading

Post by Patrizio »

Enrico, the error is considered an application MT as an application ST with an extra function.

MT applications are designed especially for parallel processes (we use .NET MT app for processing many ascii files at same time).
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Multithreading

Post by Enrico Maria Giordano »

Patrizio,
Patrizio wrote:Enrico, the error is considered an application MT as an application ST with an extra function.

MT applications are designed especially for parallel processes (we use .NET MT app for processing many ascii files at same time).
That's why I prefer background tasks. :-)

EMG
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: Multithreading

Post by Patrizio »

Enrico Maria Giordano wrote:Patrizio,

That's why I prefer background tasks. :-)

EMG
It depends on what you need to do, I use bgtasks to check if there is connectivity and check for sw updates.
Post Reply