Re: [fpc-pascal] THashedStringList vs TFPHashTable
On 28/09/06, Dean Zobec <[EMAIL PROTECTED]> wrote: It's a typical use. Choose an appropriate HashTableSize when creating the container (approx.the number of the elements you are going to store or more), you can test it with different hash functions and see through the statistics which one is better (the longer the chains i.e. more void slots, the longer the fetch times). Dean Thanks Dean. We are starting off with about 3400 objects and will be growing from there, but not at a rapid pace. Wow, only realized it now. Those objects are math lessons created over the last 8 years. Quite a collection. :-) Oh, and for those wondering, I'm not fully populating all 3400+ objects, they only contain enough information to appear in a treeview. A proxy pattern is used to populate each object only when needed. Regards, - Graeme - -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Threading support under FPC
Hi, How good is the threading support in Free Pascal? I'm using 2.1.1. I haven't used threading before under FPC and am about to revamp an in-house application to support mutliple threads. I don't want to start the app and then find out that there is some major stability issues with threading support. Anybody find issues with FPC's threading support? Any special params that I need to pass to the compiler? Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threading support under FPC
> How good is the threading support in Free Pascal? I'm using 2.1.1. I > haven't used threading before under FPC and am about to revamp an > in-house application to support mutliple threads. I don't want to > start the app and then find out that there is some major stability > issues with threading support. Anybody find issues with FPC's > threading support? Any special params that I need to pass to the > compiler? - On *nix import cthreads as first unit of your project/mainprogram. - Indy doesn't work on some platforms, notably FreeBSD. Linux and Windows seem to work. OS X unknown. - Threadvar's are initialised to the value of the mother program. This can be dangerous for e.g. filevariables. (?) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threading support under FPC
> Hi, > How good is the threading support in Free Pascal? I'm using 2.1.1. I > haven't used threading before under FPC and am about to revamp an > in-house application to support mutliple threads. I don't want to > start the app and then find out that there is some major stability > issues with threading support. Anybody find issues with FPC's > threading support? Any special params that I need to pass to the > compiler? > Regards, > - Graeme - If it didn't change recently, thread priority doesn't work under Win32 (you can change the property, but it has no effect). And I was told, it could be possible to use WinAPI SetThreadPriority etc manually. (It appeared that I didn't really need it, so I didn't check it.) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Threads executing in sequence instead of parallel
We have a problem!!! The test project /fcl/tests/threads.pp as well as a Sort Demo (Bubble, Section and Quick Sort) all execute the threads in sequence, waiting for the previous thread to complete, before the next one executes. Kind of defeats the point of using threads. The Sort Demo, which is a port of the Threads demo included with Delphi 7, shows this clearly. I can archive and post the source, but you would need Lazarus LCL to run it as it is visual. The sort demo has three columns with identical random data. The three sort methods are applied to each column respectively and gives visual feedback as it sorts the data (horizontal lines of different lengths). The threads.pp test project in fcl, shown a lot of a's on the screen and after a while, starts displaying b's on the screen. Looking at the source, I gather the a's and b's are supposed to be mixed as each thread gets processor time. I am using FPC 2.1.1 (svn version from a week ago) and running it under Ubuntu Linux 6.10 on x86 CPU (Pentium 4). Regards, - Graeme - -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
> The test project /fcl/tests/threads.pp I see random alteration of a and b here. > The threads.pp test project in fcl, shown a lot of a's on the screen > and after a while, starts displaying b's on the screen. Looking at > the source, I gather the a's and b's are supposed to be mixed as each > thread gets processor time. If you touch a key, only a's will be displayed. This is the programs behaviour. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
ok, I see hundreds of a's - press b and quite a bit later I see hundreds of b's. Do you have lazarus? I can then post the Sort Demo to show that one as well. Regards, - Graeme - On 28/09/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: > The test project /fcl/tests/threads.pp I see random alteration of a and b here. > The threads.pp test project in fcl, shown a lot of a's on the screen > and after a while, starts displaying b's on the screen. Looking at > the source, I gather the a's and b's are supposed to be mixed as each > thread gets processor time. If you touch a key, only a's will be displayed. This is the programs behaviour. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
Attached is the Sort Demo - for incase you have Lazarus. Graeme. On 28/09/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: ok, I see hundreds of a's - press b and quite a bit later I see hundreds of b's. Do you have lazarus? I can then post the Sort Demo to show that one as well. Regards, - Graeme - On 28/09/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: > > The test project /fcl/tests/threads.pp > > I see random alteration of a and b here. > > > The threads.pp test project in fcl, shown a lot of a's on the screen > > and after a while, starts displaying b's on the screen. Looking at > > the source, I gather the a's and b's are supposed to be mixed as each > > thread gets processor time. > > If you touch a key, only a's will be displayed. This is the programs > behaviour. > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- There's no place like 127.0.0.1 -- There's no place like 127.0.0.1 Threads_Sort_Demo.tar.gz Description: GNU Zip compressed data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
Just to give some more feedback. Using that same Sort App, I compiled it under Delphi 7, and ran it under Linux using WINE and the threading worked correctly. So somewhere in FPC or Lazarus lies the problem. Yeah I know, not very specific. :-) Graeme. On 28/09/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: Attached is the Sort Demo - for incase you have Lazarus. Graeme. On 28/09/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: > ok, I see hundreds of a's - press b and quite a bit later I see > hundreds of b's. > > Do you have lazarus? I can then post the Sort Demo to show that one as well. > > Regards, > - Graeme - > > > On 28/09/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: > > > The test project /fcl/tests/threads.pp > > > > I see random alteration of a and b here. > > > > > The threads.pp test project in fcl, shown a lot of a's on the screen > > > and after a while, starts displaying b's on the screen. Looking at > > > the source, I gather the a's and b's are supposed to be mixed as each > > > thread gets processor time. > > > > If you touch a key, only a's will be displayed. This is the programs > > behaviour. > > > > ___ > > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > -- > There's no place like 127.0.0.1 > -- There's no place like 127.0.0.1 -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
Graeme Geldenhuys wrote: Just to give some more feedback. Using that same Sort App, I compiled it under Delphi 7, and ran it under Linux using WINE and the threading worked correctly. So somewhere in FPC or Lazarus lies the problem. Yeah I know, not very specific. :-) Can you try running the example on windows using fpc/lazarus? Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
The only FPC/Lazarus for windows I have is under the same VMWare session as I used for Delph 7. And yes it works there, using FPC 2.0.2 with a Lazarus 0.9.15 (9152). I'll be at home in a hour, so then I can try under FPC 2.1.1 and latest Lazarus. Regards, - Graeme - On 28/09/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: Graeme Geldenhuys wrote: > Just to give some more feedback. Using that same Sort App, I compiled > it under Delphi 7, and ran it under Linux using WINE and the threading > worked correctly. So somewhere in FPC or Lazarus lies the problem. > Yeah I know, not very specific. :-) Can you try running the example on windows using fpc/lazarus? Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Threads executing in sequence instead of parallel
So far using FPC 2.0.2 and 2.0.4 and latest Lazarus (svn) it works fine under Windows. I am now busy building FPC 2.1.1 (svn) under Windows and will redo the whole process. Will post the result shortly Regards, - Graeme - On 28/09/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: Graeme Geldenhuys wrote: > Just to give some more feedback. Using that same Sort App, I compiled > it under Delphi 7, and ran it under Linux using WINE and the threading > worked correctly. So somewhere in FPC or Lazarus lies the problem. > Yeah I know, not very specific. :-) Can you try running the example on windows using fpc/lazarus? Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Threads executing in sequence instead of parallel
Ok, I have tried this under Windows and Linux, with FPC 2.0.2, 2.0.4 and 2.1.1. This seems to only be a problem under Linux. Threading works fine under Windows (via WINE or native), but is screwed under Linux native! Under Linux, it has been tested with 2.0.4 and 2.1.1 (I saw no point testing it with 2.0.2 as I don't use that version anymore under Linux). Threading runs sequential (one thread, after the other) in Linux, instead of in parallel which totally defeats the point of threads. I take this as a critical bug with FPC - unless someone can proof otherwise. More testing under Linux revealed that I have quite a few apps, that are affected by this. I have tested this on 4 different machines all with the same outcome. Is any body else using threading in their applications? Are you experiencing the same issues under Linux? If so, I will submit a bug report with a sample app showing the issue tomorrow. This is the output of 'uname -a' to show my kernel version. [EMAIL PROTECTED]:~$ uname -a Linux graemeg-laptop 2.6.15-27-386 #1 PREEMPT Sat Sep 16 01:51:59 UTC 2006 i686 GNU/Linux Regards, - Graeme - On 28/09/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: We have a problem!!! The test project /fcl/tests/threads.pp as well as a Sort Demo (Bubble, Section and Quick Sort) all execute the threads in sequence, waiting for the previous thread to complete, before the next one executes. Kind of defeats the point of using threads. The Sort Demo, which is a port of the Threads demo included with Delphi 7, shows this clearly. I can archive and post the source, but you would need Lazarus LCL to run it as it is visual. The sort demo has three columns with identical random data. The three sort methods are applied to each column respectively and gives visual feedback as it sorts the data (horizontal lines of different lengths). The threads.pp test project in fcl, shown a lot of a's on the screen and after a while, starts displaying b's on the screen. Looking at the source, I gather the a's and b's are supposed to be mixed as each thread gets processor time. I am using FPC 2.1.1 (svn version from a week ago) and running it under Ubuntu Linux 6.10 on x86 CPU (Pentium 4). Regards, - Graeme - -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Threads executing in sequence instead of parallel
Graeme Geldenhuys wrote: Ok, I have tried this under Windows and Linux, with FPC 2.0.2, 2.0.4 and 2.1.1. I have tested this on 4 different machines all with the same outcome. Is any body else using threading in their applications? Are you experiencing the same issues under Linux? If so, I will submit a bug report with a sample app showing the issue tomorrow. I know about this report: http://www.freepascal.org/mantis/view.php?id=1906 Threading related, but not the same, as you are not using synchronize, are you? Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Threads executing in sequence instead of parallel
On 28/09/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: I know about this report: http://www.freepascal.org/mantis/view.php?id=1906 Threading related, but not the same, as you are not using synchronize, are you? Vincent Do you mean like below - which then means, I do use synchronize. I use synchronize to draw on the main form (running in the main thread). I don't get any lockups as that bug report says, but then I am running under Ubuntu that uses Gnome desktop. Again, no such issues under Windows. TSortThread is the base class for my three different Sorting threads, so they all use this function. procedure TSortThread.VisualSwap(A, B, I, J: Integer); begin FA := A; FB := B; FI := I; FJ := J; Synchronize(@DoVisualSwap); end; They never attached a sample application, so I can't try it on my system to see if I get the same issues as they do, but as I stated, I don't get lockups, only that the threads run in sequence - one after the other. What platform are you running on, Windows? Regards, - Graeme - -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Threads executing in sequence instead of parallel
What is also very interresting, which I thought I would share. I added three more Bubble Sort columns to my test app (total of 6 sort threads - knowing bubble sort is the slowest). I then created all 6 threads suspended (t1 thru t6 in order). I then resumed the threads in the order t1, t6, t2 thu t5. They still executed in the *creation order* ( t1 thru t6.) and not the resumed order. Meaning t1 started and completed, t2 started and complete, etc. Not sure if this might help the debug process... Regards, - Graeme - On 28/09/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: On 28/09/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: > I know about this report: > http://www.freepascal.org/mantis/view.php?id=1906 > > Threading related, but not the same, as you are not using synchronize, > are you? > > Vincent Do you mean like below - which then means, I do use synchronize. I use synchronize to draw on the main form (running in the main thread). I don't get any lockups as that bug report says, but then I am running under Ubuntu that uses Gnome desktop. Again, no such issues under Windows. TSortThread is the base class for my three different Sorting threads, so they all use this function. procedure TSortThread.VisualSwap(A, B, I, J: Integer); begin FA := A; FB := B; FI := I; FJ := J; Synchronize(@DoVisualSwap); end; They never attached a sample application, so I can't try it on my system to see if I get the same issues as they do, but as I stated, I don't get lockups, only that the threads run in sequence - one after the other. What platform are you running on, Windows? Regards, - Graeme - -- There's no place like 127.0.0.1 -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Threads executing in sequence instead of parallel
Graeme Geldenhuys schreef: On 28/09/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: I know about this report: http://www.freepascal.org/mantis/view.php?id=1906 Threading related, but not the same, as you are not using synchronize, are you? Vincent Do you mean like below - which then means, I do use synchronize. I use synchronize to draw on the main form (running in the main thread). I don't get any lockups as that bug report says, but then I am running under Ubuntu that uses Gnome desktop. Again, no such issues under Windows. TSortThread is the base class for my three different Sorting threads, so they all use this function. procedure TSortThread.VisualSwap(A, B, I, J: Integer); begin FA := A; FB := B; FI := I; FJ := J; Synchronize(@DoVisualSwap); end; They never attached a sample application, so I can't try it on my system to see if I get the same issues as they do, but as I stated, I don't get lockups, only that the threads run in sequence - one after the other. What platform are you running on, Windows? All gui stuff I run on windows. Non visual test apps, I can run on linux too. If I really want I could do GUI in linux too, but I don't know too much about gtk and I rather spent time on improving things on the windows platform. I thought in your initial mail your were talking about having a console test app with threads. Synchronize is harder then, because you have to call CheckSynchronize yourself. Vincent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal