• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

slow wage calculation

 
Greenhorn
Posts: 5
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
arash kolivand
Greenhorn
Posts: 5
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5
Android Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 5
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic