Hi,

On 9/28/05, Lefteris Tsintjelis <[EMAIL PROTECTED]> wrote:
>
> John McCaskey wrote:
> > Hello again,
> >
> > I modified your threading code to use a thread pool. Here are my
> results:
>
> Hello,
>
> I modified the thread pool a bit to get rid of that lock ASAP. It is safe
> to get rid of that lock right after mysql_store_results.


I wasnt quite sure about the safety of the error output that occured later
on, but it is true for sure in the case of no errors occuring releasing
sooner is safe. Good optimization.

http://dev.mysql.com/doc/mysql/en/threaded-clients.html
>
> The conclusion I draw from all this is that if you have a very fast
> connection to your db its best NOT to use threading at all if your queries
> are simple and you expect the results fast.


I dont think that is neccesarily true, it will also depend on what type of
queries. But for your situation it does appear true.

Here is another interesting thing though, if multi threading is used, I
> got the best results by using 2 connections, I am also using dual CPUs
> (i%CONNECTIONS). I guess everyone can draw its own conclusions depending
> on his needs but for me, and since I only need to do *few, simple, local*
> queries, looks like I can "live" without the multi thread over head for
> now. The more complex are the queries, slower the connections and higher
> the response time is, (the slower the answer you get in general) then
> multi threading could be a winner.
>
> -- Clearly the winner ---


<snip>

Given your connections are local and you have 2 cpus Id be interested to see
4 connections, 4 threads, 2500 queries per thread. Opening many more threads
than you have cpus is always going to be a bad idea unless there is some
sort of blocking io operation (like waiting for the network, or a disk read)
or something occuring in each thread so that alot of the time spent is just
idle. However, with just 2-4 threads and connections you should be able to
execute the queries in parallell as you actually have the hardware to do so,
while avoiding alot of the thread overhead that you saw with 100. You will
likely still go with single threaded for your situation, but it would be
very interesting to me if we could see the scenario I just outlined posted
to compare to your last posted results.

John

Reply via email to