• 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

Performance tuning: where to start from.

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
please give me some advice about the performance tuning.
Last few days I have been trying TPTP and Netbeans profiler, the latter looks much better.

Could you explain me please:

1) what is the main idea of using the profiler?

Here some points as far as I understand by myself:
- find method with the longest execution time
- find redundant method calls
- find redundant object instances

What else?
How can I use the memory statistics?
How can I identify the memory leaks?
Is there any books with some words about the basics of Java performance?

2) If I use executable JAR or even compile EXE file, whether the performance is to be reduced or raised?

Thanks!
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good questions. I have more an intuitive understanding of the tuning process, but haven't tried to articulate it in any detail. I suspect profiling is different things to different people, but most people would agree that it encompasses performance monitoring.

Here is the wikipedia definition of profiler:

In software engineering, program profiling, software profiling or simply profiling, a form of dynamic program analysis (as opposed to static code analysis), is the investigation of a program's behavior using information gathered as the program executes. The usual purpose of this analysis is to determine which sections of a program to optimize - to increase its overall speed, decrease its memory requirement or sometimes both.




<<what is the main idea of using the profiler?>>
Using a profiler allows you to see which part of your code takes the most time. This isn't always often as you may have a very fast routine, but it is invoked millions of times and another one that takes a long time but is only invoked once. In this case it would probably make more sense to tune the faster routine. It is also difficult to guess which routines will be slow just by looking at them. Often our intuition on where to tune is wrong. A profiler helps overcome this weakness by putting a little science and analysis behind what we tune. Plus it gives us a baseline that allows us to compare performance over different iterations as the program evolves.

I think of a profiler as more of a development and test activity, but it is also important to monitor in production as often real users can do surprising things with an application. Also, I think of profilers as more of a performance tool. As you mention there are other aspects to testing your code that are important such as bandwidth consumption, cpu utilization, memory usage, object creation, IO, code coverage, exception tracking and no double more. Something you should also gain in the process isn't really a number, but a better understanding of the normal operations of your system including which subsystems are most popular, and what features are overly complicated. All of this knowledge is powerful downstream when you need to trouble shoot any problems that may arise.

I would be curious to hear from other people if the term 'profiler' covers all these and if not, is there a term that encompasses all of these concepts. Some 'profilers' do more than others. Essentially it is Metrics based testing and tracking.

<<Here some points as far as I understand by myself:
- find method with the longest execution time>>
Total execution time is probably more important that longest execution time.

<<- find redundant method calls>>
Not sure what you mean by redundant method calls.

<<- find redundant object instances>>
I am guessing you mean situations where a large number of objects are created. Some profilers do this others don't.

<<What else?
How can I use the memory statistics?
How can I identify the memory leaks?
>>
All of these are important. Again some profilers do this others don't.

<<Is there any books with some words about the basics of Java performance?>>
I haven't read any in a while, but back in the day there was 'Java Performance Tuning'. It would be nice if there was a book that talked more about software runtime metrics, tracking and monitoring in general. Is there one?

<<2) If I use executable JAR or even compile EXE file, whether the performance is to be reduced or raised?>>
Depends on the situation I am sure. Usually your best tuning tip is writing good maintainable, changeable code and profiling it to see where to tune. This can give orders of magnitude improvement whereas compiling to an exe would probably give incremental improvements. Two easy things I have done that made big impacts on performance: 1)using the lastest jvm (overall each version from 1.1, 1.2, 1.4, 1.5, 1.6 and now 1.7 all seem to get faster). 2) running your code with the -server option. Of course these aren't universal solutions and should be tested on your code.

Also read the java performance tuning faq below.

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another good web site with lots of information about Java Performance - http://www.javaperformancetuning.com/
 
Dmitry Zhuravlev
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, thank you for the replies.

At the moment I have the following problem.

It looks like the memory grows significally when I just redraw plot in my application. After several redraws I receive


It looks like memory leak. But how can I identify it using the profiler? I look at the objects with the growing memory and all that objects are not from my packages, but from the packages Eclipse TPTP calls 'default'. These objects are arrays of primitives. And their size grows with each redrawal of my plot, though it shouldn't. How can I identify where is the problem?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dmitry Zhuravlev wrote:Guys, thank you for the replies.

At the moment I have the following problem.

It looks like the memory grows significally when I just redraw plot in my application. After several redraws I receive


It looks like memory leak. But how can I identify it using the profiler? I look at the objects with the growing memory and all that objects are not from my packages, but from the packages Eclipse TPTP calls 'default'. These objects are arrays of primitives. And their size grows with each redrawal of my plot, though it shouldn't. How can I identify where is the problem?



Did you try to add parameters "-Xms128m -Xmx256m" to increase memory when you run it?
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you tell us how much heap size you have given ??
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dmitry Zhuravlev wrote:Guys, thank you for the replies.

At the moment I have the following problem.

It looks like the memory grows significally when I just redraw plot in my application. After several redraws I receive


It looks like memory leak. But how can I identify it using the profiler? I look at the objects with the growing memory and all that objects are not from my packages, but from the packages Eclipse TPTP calls 'default'. These objects are arrays of primitives. And their size grows with each redrawal of my plot, though it shouldn't. How can I identify where is the problem?


Hello,
could you show part of code with passing values to plot api?
 
Dmitry Zhuravlev
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
thank you for the replies.

It turned out that I have forgotten to clear the datasets I was using to plot the chart. This is why each new chart redrawal was taking more and more memory from my machine.

Justin, Sandeep, thank for the hint, I should play with the heap size anyway.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic