Difference between revisions of "EclipseLink/DesignDocs/398411"

From Eclipsepedia

Jump to: navigation, search
(API)
(Query Results Cache Invalidation)
 
(2 intermediate revisions by one user not shown)
Line 54: Line 54:
 
Any change (insert/update/delete) to any of the classes that the query returns will cause the query results for that query to be invalidated (cleared).
 
Any change (insert/update/delete) to any of the classes that the query returns will cause the query results for that query to be invalidated (cleared).
 
Changes to classes not used in the query (joins are considered used) will not affect the query results.
 
Changes to classes not used in the query (joins are considered used) will not affect the query results.
 +
 +
Insert, update, delete, update-all, delete-all operations will invalidate the query result cache.  Also cache coordination and DCN changes will invalidate the query cache when used.
  
 
This is coarse grained invalidation, any insert, update or delete will cause all of the queries for that class to be invalidated, even if the query was not affected by that modification.  Fine grained invalidation would be prohibitively expensive, as you would need to re-run the query in-memory on the object, but may be considered as a future enhancement.
 
This is coarse grained invalidation, any insert, update or delete will cause all of the queries for that class to be invalidated, even if the query was not affected by that modification.  Fine grained invalidation would be prohibitively expensive, as you would need to re-run the query in-memory on the object, but may be considered as a future enhancement.
Line 111: Line 113:
 
= Config files =
 
= Config files =
  
 +
===persistence.xml===
 +
 +
Query results cache:
 +
* "eclipselink.cache.query-results"="true/false"
 +
 +
Concurrent processing:
 +
* "eclipselink.concurrent"="true/false"
 +
* "eclipselink.concurrent.thread-pool.size"="<int>"
 +
 +
Tuning:
 +
* "eclipselink.tuning"="Safe/Standard/<custom-class>"
  
 
= Documentation =
 
= Documentation =
Line 137: Line 150:
  
 
= Future Considerations =
 
= Future Considerations =
 +
* Fine grained query result cache invalidation.
 +
* Other tuning configurations.
 +
 
Continually improve performance.
 
Continually improve performance.

Latest revision as of 12:35, 17 January 2013

[edit] Design Specification: Performance and Concurrency

ER 398411

Feedback

[edit] Document History

Date Author Version Description & Notes
2013-01-17 James 0.1 Draft

[edit] Project overview

This project groups several smaller performance related bug fixes and enhancements into a single unit. Its' goal is the improve the performance, concurrency and scalability of the product.

[edit] Concepts

Performance is concerned about reducing CPU usage and finding more optimal methods of processing operations.

Concurrency is concerned with reducing contention and improving multi-threaded and multi-CPU performance.

Scalability is concerned with clustering, large workloads and data.

[edit] Requirements

The goal of this project is to ensure that our product remains the leading high-performance persistence solution. Areas of improvement are determined through performance comparison with other persistence products and benchmarking.


[edit] Design Constraints

The goal of the project is to improve performance of common usage patterns. Fringe features and usage patterns will not be specifically targeted unless found to be highly deficient.

Any optimization must also be weighed in its' impact on usability, and spec compliance. Optimizations that may have a large negative impact to usability may need to be only enabled through specific configuration.

[edit] Functionality

Each specific performance improvement is discussed separately below.

[edit] Query Results Cache Invalidation

https://bugs.eclipse.org/bugs/show_bug.cgi?id=352500

Query results caching is currently supported on any named query. The query results are never invalidated when changes occur, so the cache can become out of synch with the database. Note, the object is the query results are kept up to date, but if changes to the objects, or new/deleted objects affect the query results, this is not reflected. The query results cache does support timeToLive and daily invalidation.

A option will be added to invalidate the query results cache, this will be enabled by default. Any change (insert/update/delete) to any of the classes that the query returns will cause the query results for that query to be invalidated (cleared). Changes to classes not used in the query (joins are considered used) will not affect the query results.

Insert, update, delete, update-all, delete-all operations will invalidate the query result cache. Also cache coordination and DCN changes will invalidate the query cache when used.

This is coarse grained invalidation, any insert, update or delete will cause all of the queries for that class to be invalidated, even if the query was not affected by that modification. Fine grained invalidation would be prohibitively expensive, as you would need to re-run the query in-memory on the object, but may be considered as a future enhancement.

A option will be provided to enable query results cache on all named queries.

[edit] Concurrent Processing

https://bugs.eclipse.org/bugs/show_bug.cgi?id=386398

Concurrent processing could be used in many areas to improve performance.

An option will be provided on the Session to process query results concurrently. This will cause the rows to be fetched on a separate thread, allowing the objects to be built concurrently to the row fetching. This can improve the performance of large queries.

An option will be provided on a LoadGroup to load the relationships concurrently. This will use a separate thread for each relationship, allowing the related objects to be fetched and built concurrently to building the parent object and other relationships.

WeakIdentityMap cache key cleanup will occur on a separate thread for concurrent sessions. This avoids blocks the main thread and allows the cleanup to occur in the background.

A fixed size thread pool (default 32 threads) will be used for concurrent processing. The thread pool will be defined on the ServerPlatform, and a platform may choose to use the server's thread pool (none currently do). The thread pool will be configurable through persistence unit properties.

A persistence unit property should be provided to enable concurrency.

Concurrent processing will only affect response time, not throughput, as it only make better use of idle CPU. On a fully loaded system, it could decrease throughput as additional locking overhead is required.

[edit] Tuning

https://bugs.eclipse.org/bugs/show_bug.cgi?id=398193

A SessionTuner interface will be added to facilitate template tuning configurations. This will allow an application to be easily tuned for development versus production, or for various deployment configurations.

A tuner will receive callbacks during deployment to tune a JPA configuration. preDeploy() will allow tuning of persistence unit properties, deploy() will allow tuning of a Session through native API, and postDeploy() will allow tuning after the Session has been initialized and connected to the database.

A persistence unit property will be added to configure the tuner. A SafeModeTuner will be provided to tune for debugging and a default StandardTuner will be provided.

[edit] Testing

Both the existing performance and concurrency tests and pubic benchmarks will be used to monitor and evaluate performance improvements.


[edit] API

Query results cache invalidation:

  • QueryResultsCachePolicy
    • setInvalidateOnChange(boolean)
  • Project
  • setDefaultQueryResultsCachePolicy(QueryResultsCachePolicy)

Concurrent processing:

  • Session
    • setIsConcurrent(boolean)
  • LoadGroup
    • setIsConcurrent(boolean)

Tuning:

  • SessionTuner
  • SafeModeTuner
  • StandardTuner

[edit] Config files

[edit] persistence.xml

Query results cache:

  • "eclipselink.cache.query-results"="true/false"

Concurrent processing:

  • "eclipselink.concurrent"="true/false"
  • "eclipselink.concurrent.thread-pool.size"="<int>"

Tuning:

  • "eclipselink.tuning"="Safe/Standard/<custom-class>"

[edit] Documentation

[edit] Open Issues

Issue # Owner Description / Notes

[edit] Decisions

Issue # Description / Notes Decision

[edit] Future Considerations

  • Fine grained query result cache invalidation.
  • Other tuning configurations.

Continually improve performance.