Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/Performance/Performance Monitoring and Profiling"

m (How to Access the EclipseLink Profiler Results)
m (Performance Profiling)
Line 1: Line 1:
 +
{{EclipseLink_Toc}
 
=Performance Profiling=
 
=Performance Profiling=
  

Revision as of 11:11, 16 June 2010

{{EclipseLink_Toc}

Performance Profiling

Measuring EclipseLink Performance with the EclipseLink Profiler

The most important challenge to performance tuning is knowing what to optimize. To improve the performance of your application, identify the areas of your application that do not operate at peak efficiency. The EclipseLink performance profiler helps you identify performance problems by logging performance statistics for every executed query in a given session.

Elug note icon.png

Note: You should also consider using general performance profilers such as JDeveloper or JProbe to analyze performance problems. These tools can provide more detail that may be required to properly diagnose a problem.


The EclipseLink performance profiler logs the following information to the EclipseLink log file (for general information about EclipseLink logging, see Logging):

  • query class;
  • domain class;
  • total time, total execution time of the query, including any nested queries (in milliseconds);
  • local time, execution time of the query, excluding any nested queries (in milliseconds);
  • number of objects, the total number of objects affected;
  • number of objects handled per second;
  • logging, the amount of time spent printing logging messages (in milliseconds);
  • SQL prepare, the amount of time spent preparing the SQL script (in milliseconds);
  • SQL execute, the amount of time spent executing the SQL script (in milliseconds);
  • row fetch, the amount of time spent fetching rows from the database (in milliseconds);
  • cache, the amount of time spent searching or updating the object cache (in milliseconds);
  • object build, the amount of time spent building the domain object (in milliseconds);
  • query prepare, the amount of time spent to prepare the query prior to execution (in milliseconds);
  • SQL generation, the amount of time spent to generate the SQL script before it is sent to the database (in milliseconds).


Elug note icon.png

Note: Use the EclipseLink profiler to profile single-threaded finite use cases to determine the bottle neck.

Do not use the EclipseLink profiler to enable monitoring of a long-running multi-threaded server.


This section includes information on the following topics:


How to Configure the EclipseLink Performance Profiler

To enable the EclipseLink performance profiler, select the EclipseLink profiler option when configuring your session (see Configuring a Performance Profiler).

When using JPA the profiler can be set in your persistence.xml through the persistence property "eclipselink.profiler" to "PerformanceProfiler". See the ProfilerType in the config package for other profiling options.

The EclipseLink performance profiler is an instance of org.eclipse.persistence.tools.profiler.PerformanceProfiler class. It provides the following public API:

  • logProfile – enables the profiler;
  • dontLogProfile – disables the profiler;
  • logProfileSummary – organizes the profiler log into a summary of all the individual operation profiles including operation statistics like the shortest time of all the operations that were profiled, the total time of all the operations, the number of objects returned by profiled queries, and the total time that was spent in each kind of operation that was profiled;
  • logProfileSummaryByQuery – organizes the profiler log into a summary of all the individual operation profiles by query;
  • logProfileSummaryByClass – organizes the profiler log into a summary of all the individual operation profiles by class.

How to Access the EclipseLink Profiler Results

The simplest way to view EclipseLink profiler results is to read the EclipseLink log files with a text editor. For general information about EclipseLink logging, such as logging file location, see Logging.

This example shows an example of the EclipseLink profiler output.

Performance Profiler Output

Begin Profile of{
ReadAllQuery(com.demos.employee.domain.Employee)
Profile(ReadAllQuery,# of obj=12, time=1399,sql execute=217,
prepare=495, row fetch=390, time/obj=116,obj/sec=8)
} End Profile

The second line of the profile contains the following information about a query:

Elug vote bug.png
Vote for enhancement bug #310820 to add nanosecond (10^6 ms) resolution
  • ReadAllQuery(com.demos.employee.domain.Employee): specific query profiled, and its arguments.
  • Profile(ReadAllQuery: start of the profile and the type of query.
  • # of obj=12: number of objects involved in the query.
  • time=1399: total execution time of the query (in milliseconds).
  • sql execute=217: total time spent executing the SQL statement.
  • prepare=495: total time spent preparing the SQL statement.
  • row fetch=390: total time spent fetching rows from the database.
  • time/obj=116: number of milliseconds spent on each object.
  • obj/sec=8: number of objects handled per second.



Eclipselink-logo.gif
Version: DRAFT
Other versions...