Hello,
I have an application that has some 10 resultsets(RS) as an output for many different users.
So the
user 1 (U1) has the 10 RS (R1, R2, R3..... )
user 2 (U2) has the 10 RS (R1, R2, R3..... )
..................
.................
user n (Un) has the 10 RS (R1, R2, R3..... )
Then I am itereating all the 10 RS. and populating the Models(Getter setter methods classes).
this is taking lot of time as the resultsets have some millions of records and there are thousands of users.
Can I change my application so that all the users will be handled parallely through the multithreaded way.
I mean, is the threading will benefit the performance issues?
All the replys will be highly appreciated.
Thanks in advance.
Suhas S
-
Multithreaded programming (11 messages)
- Posted by: suhas shahapurkar
- Posted on: July 05 2004 10:34 EDT
Threaded Messages (11)
- Multithreaded programming by Kamati Pura on July 06 2004 00:28 EDT
- Multithreaded programming by suhas shahapurkar on July 06 2004 05:21 EDT
- Multithreaded programming by Quartz Quartz on July 06 2004 12:17 EDT
- Multithreaded programming by suhas shahapurkar on July 06 2004 12:41 EDT
- Multithreaded programming by Race Condition on July 06 2004 13:51 EDT
-
Multithreaded programming by Kamati Pura on July 06 2004 02:28 EDT
-
Multithreaded programming by Race Condition on July 06 2004 02:50 EDT
-
Multithreaded programming by Kamati Pura on July 07 2004 12:26 EDT
-
Multithreaded programming by Race Condition on July 07 2004 06:18 EDT
- interresting reading: MAJC by Quartz Quartz on July 07 2004 12:04 EDT
-
Multithreaded programming by Race Condition on July 07 2004 06:18 EDT
-
Multithreaded programming by Kamati Pura on July 07 2004 12:26 EDT
-
Multithreaded programming by Race Condition on July 06 2004 02:50 EDT
-
Multithreaded programming by Kamati Pura on July 06 2004 02:28 EDT
- Multithreaded programming by Jose Ramon Huerga Ayuso on July 12 2004 15:16 EDT
-
Multithreaded programming[ Go to top ]
- Posted by: Kamati Pura
- Posted on: July 06 2004 00:28 EDT
- in response to suhas shahapurkar
Hey Suhas
Your application seems to be heavily loaded.
Can you give some more details about the architecture and technology, so that the actual constraints can be judged. This might help in attacking thr true bottlenecks in the system.
Cheers,
Ajay -
Multithreaded programming[ Go to top ]
- Posted by: suhas shahapurkar
- Posted on: July 06 2004 05:21 EDT
- in response to suhas shahapurkar
Thanks for the reply Ajay,
Actually this application is a Java Application (Jdk1.3) and on Solaris Machine with v high configuration. The database we are using is Sybase 12.x
Is this info. you are asking for?
Actually my idea is to deal populate the models for all the users in parallel way. Is this possible? I mean will this reduce the time or will just increase the memory heap.
Thanks
Suhas S -
Multithreaded programming[ Go to top ]
- Posted by: Quartz Quartz
- Posted on: July 06 2004 12:17 EDT
- in response to suhas shahapurkar
unless you got more than 1 CPU, multi threading your 10 db queries is only gonna make all of them 10 times slower on avg (plus or minus, given db caching, disk i/o perf +/- raid, or even balanced DB server tier).
And even with 10 cpu, if you have avg 100 concurrent queries (let's say 10 users querying), is not gonna change a things to multithread, since all CPU are all occupied already.
Rule of thumb, when a system is saturated, multithreading doesn't help, even waste cpu through context switching.
If your CPU(s) are mostly idle (~10%), then chances are the time wasted is at db server accesing disk (and network latency if db tier). In which case you better have a raid and a 1 gigabit/s network card (+very optimized tcp/ip stack).
In other words, there is no point in multithreading if the code to be multithreaded is not blocking/waiting, because CPU is not idle in non-blocking code (beside few memory access cycle that occurs anyway in any code) and multithreading just adds context switching.
If you have hyperthreaded cpu, multithreading could help if threads are doing very different type of work (i/o, memory, arithmetic) which is not what you intend to do. -
Multithreaded programming[ Go to top ]
- Posted by: suhas shahapurkar
- Posted on: July 06 2004 12:41 EDT
- in response to Quartz Quartz
Thank you very much!!
Regards
Suhas -
Multithreaded programming[ Go to top ]
- Posted by: Race Condition
- Posted on: July 06 2004 13:51 EDT
- in response to Quartz Quartz
Quartz,
Does multi-threaded code need to run on a multi-processor cpu to realize any benefit from the multi-threading? In other words, does a single processor CPU run threads consecutively or in parallel?
Thanks. -
Multithreaded programming[ Go to top ]
- Posted by: Kamati Pura
- Posted on: July 06 2004 14:28 EDT
- in response to Race Condition
Well, back to computer architecture basics
Traditional von Newman machines are called SISD (Single Instruction stream Single Data stream) machines can only do one job at any given instant of time. Thats why Parallel processing machines have multiprocessors or are distributed in nature.
Anyways, i dont really have the low down on Hyper Threading technology but otherwise, one cpu can process one instruction at any given instance of time.
I dont know whether Suhas has a lot of load on his system's processors or not. But like Quartz said, it makes sense to have threading only when u expect ur processor is going to remain free for a while. Otherwise, its the same bottleneck, this way or that way.
What u might need is better faster hardware, or maybe a redesign into a distributed system ( I know im dreamin with this, but what the hell)
Cheers
Ajay -
Multithreaded programming[ Go to top ]
- Posted by: Race Condition
- Posted on: July 06 2004 14:50 EDT
- in response to Kamati Pura
Thanks Ajay.
So, are these two statements true?
Code that is deployed on a single processor CPU will not realize any benefit from multi-threading. True or false?
A 'synchronized' code block is irrelevant when deployed on a single processor CPU. True or false?
cheers. -
Multithreaded programming[ Go to top ]
- Posted by: Kamati Pura
- Posted on: July 07 2004 00:26 EDT
- in response to Race Condition
The first statement is conditional.
It all depends on how much time your CPU is free.
eg. Lets say ur program needs to do two jobs
1. Read a line from the keyboard and use the data in some calculation.
2. Send a mail to someone ( the mail has nothing to do with the 1st job)
So while u wait for the user to key in data( and ur CPU does nothing during this time), u would be better off spawning a thread and going ahead with sending the mail.
However, if ur program has to do immense processor intensive calculation(without waiting for anything), and send the mail too, then ur not getting much out of spawning new threads for the mailing.
The 2nd statement is not true.
This is because if u spawn different threads, that are going to use the same object in memory, ur processor will switch between these threads to do something called "timesharing"( which thread gets how much time depends on the threadng model and the priority of each thread). Thus it is possible that while Thread 1 is using object 1, it has to move out of the cpu to give thread 2 a chance to run. if object 1 is not synchronized, thread 2 can change its value before thread 1 runs again.
That is why u need synchronized code even if u have just one processor.
I hope that clarifies ur doubt.
Cheers
Ajay -
Multithreaded programming[ Go to top ]
- Posted by: Race Condition
- Posted on: July 07 2004 06:18 EDT
- in response to Kamati Pura
Thanks for the thorough explanation! -
interresting reading: MAJC[ Go to top ]
- Posted by: Quartz Quartz
- Posted on: July 07 2004 12:04 EDT
- in response to Race Condition
interresting reading:
http://arstechnica.com/cpu/4q99/majc/majc-1.html -
Multithreaded programming[ Go to top ]
- Posted by: Jose Ramon Huerga Ayuso
- Posted on: July 12 2004 15:16 EDT
- in response to suhas shahapurkar
Hello,I have an application that has some 10 resultsets(RS) as an output for many different users.So the user 1 (U1) has the 10 RS (R1, R2, R3..... )user 2 (U2) has the 10 RS (R1, R2, R3..... )...................................user n (Un) has the 10 RS (R1, R2, R3..... )Then I am itereating all the 10 RS. and populating the Models(Getter setter methods classes).
If you keep open more than two or three result sets, probably you are going to run out of cursors. I have seen a lot of problems related with cursors, and all of then got solved redesigning the application to use only a few open result sets.this is taking lot of time as the resultsets have some millions of records and there are thousands of users.
If your result set returns millions of records, maybe you should try to adjust the WHERE clauses in order to read less records. The less records you move through the network, the faster your application (and databases) run.
Jose Ramon Huerga
http://www.terra.es/personal/jrhuerga/