File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes slow wage calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "slow wage calculation " Watch "slow wage calculation " New topic
Author

slow wage calculation

arash kolivand
Greenhorn

Joined: Nov 06, 2012
Posts: 4

Hi.
I have an ERP, developed on Spring, Struts 1, Hibernate, JSP and deployed on tomcat.My database is Oracle 11.
I have module for wage caculation that shoul calculate wage for 3000 staff.

for the first staff calculation madule spend about 5 seconds but for the 1000th staff this time is about 70 seconds and increase staff by staff to 5 min.
Why?
What can I do?
Please help me.

Out of Memory Exception
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

The first step is always to get a profiler and figure out where exactly your code is spending its time. There is no point doing anything until you figure that out.

IF the first employee runs fast and things slow down the more you process, you probably have an inefficient algorithm. i.e. something that runs in O(n^2) time. However, without analyzing the actual code, that is only a guess.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
arash kolivand
Greenhorn

Joined: Nov 06, 2012
Posts: 4

the calculation algorithm is very simple.
the algorithm has a container that keep essential data for wage calculation

every time It loads essential information, like entrance and exite time and etc, for 50 staff
after that calculates wage
then, makes the container empty and call system.gc()

the algorithm for all 3000 staff does these 3 steps

I monitored It by jrockit mission control but couldn't understand what happened?

can I attach flight recording information for checking?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Just because it is simple doesn't mean it scales well. WHen you ran the profiler, what part of the code did it say was taking the most time?

Also, you shouldn't be calling gc(). Java will do that itself when need be. Java can ignore your request to do garbage collection anyway.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Frank Pavageau
Greenhorn

Joined: Jul 20, 2010
Posts: 10
Since you're using Hibernate, it could be a Session filling up, as it usually exhibits that kind of symptom. You'd then need to flush() and clear() the session regularly.

But as others have answered, you should be profiling to make sure it's the problem: doing a simple thread dump while the processing drags on might be enough to see in which part of the code it's taking time. Obviously, since you have a performance problem, what you think should work is not what actually works.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

arash kolivand wrote:the calculation algorithm is very simple.

The algorithm for a bubble sort is simple, too, but has terrible performance - O(n^2).

So, you need to follow the advice given by three different people and use a profiler to find where the time is being spent.
arash kolivand
Greenhorn

Joined: Nov 06, 2012
Posts: 4


Since you're using Hibernate, it could be a Session filling up, as it usually exhibits that kind of symptom. You'd then need to flush() and clear() the session regularly.

thanks dears
flush() and clear() solved my problem
Thanks alot Frank Pavageau
arash kolivand
Greenhorn

Joined: Nov 06, 2012
Posts: 4

Hi dears.
these days, I faced new problem at some parts of the system.
During the update of an Object, which chaneged some members value, it insert a new record and don't update loaded Object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: slow wage calculation