There and Back Again
As Quick As a Flash:
Tuning Performance in CDO
Stefan Winkler
Independent Software Developer and IT Consultant CDO Committer
[email protected] @xpomul on Twitter
CDO in a nutshell
Server
Client
Client
Client
Storage
CDO in a nutshell
Server
Client
Client
Client
Storage
CDO in a nutshell
Server
Client
Client
Client
Storage
CDOID attribute reference CDOIDCDO in a nutshell
Server
Client
Client
Client
Storage
CDOID attribute reference CDOIDCDO in a nutshell
Server
Client
Client
Client
Storage
CDOID attribute reference CDOIDStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
CDOID attribute reference CDOIDStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
attribute reference CDOID attribute referenceStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
attribute reference CDOID CDOID attribute referenceStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
attribute reference CDOID CDOID attribute referenceStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
attribute reference CDOID CDOID attribute referenceStorage
CDO in a nutshell
Server
Client
Client
Client
Storage
attribute reference CDOID CDOID attribute referenceLayers
App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
Choose the
Right Storage!
MEM Lissome DB (h2 in-proc) DB (h2 net) DB (MySQL) Hibernate (MySQL) MongoDB (net) DB4O (in-proc) 1.701 519.063 22.314 9.381 4.269 1.486 1.475 1.121time to read 10,000 objects (msec)
2.268 1.503 10.151 6.686 5.546 721 431 283
Choose the
Right Storage!
Store
Usage Scenarios
Pros
Cons
MEMStore prototyping, testing supports all CDO features not persistent LissomeStore custom CDO file-based store, optimized for performance full support plannedperformance, (no external access)custom file formatDBStore common/default solution supports all CDO
features DB selection and tuning adds to complexity HibernateStore custom DB schema required custom DB schema
and mapping only supports subset of CDO features, slower MongoDB Store No SQL DB wanted,
fast writing speeds required fast writing speeds slow reading speeds,limited commit size DB4OStore No SQL DB wanted,
fast reading speeds required fast reading speeds slower writing speedsdual licence OODB with commercial performance ? commercial licence,
Choose the Right
Database!
h2 (net) MySQL (net) PostgreSQL (net) 4.231 9.381 4.269time to read 10,000 objects
6.606 6.686 5.546
Choose the Right
Database!
h2 (net) MySQL (net) PostgreSQL (net) 4.231 9.381 4.269time to read 10,000 objects
6.606 6.686 5.546
time to write 10,000 objects (msec)
Choose the Right
Database!
h2 (net) MySQL (net) PostgreSQL (net) 4.231 9.381 4.269time to read 10,000 objects
6.606 6.686 5.546
time to write 10,000 objects (msec)
Standard Configurations !!!
App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
Choose the Right
Repository Mode!
Time
v1 v2 v3 v4 v5 v6 v7
Audit Mode
Choose the Right
Repository Mode!
Time
v1 v2 v3 v4 v5 v6 v7
Non-Audit Mode
Choose the Right
Repository Mode!
Time
0:v1 v2 v3 v4
v5 v6
Branching Mode
1:v1
2:v1
1:v2
2:v2 2:v3
Choose the Right
DBStore Mapping!
•
Audit:
•
plain vs. range-based list mapping
•
Branching:
•
plain vs. range-based list mapping
Choose the Right
DBStore Mapping!
date
sum
Order
date
sum
Product
date
sum
Product
number
price
Product
Order Order Order Orderid version date sum
1 2 3/29/12 102.34
Product Product Product Product
id version number price
2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51 Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id version index value
•
non-audit repo mode
•
no historic („audit“) views
Choose the Right
DBStore Mapping!
Order Order Order Orderid version date sum
1 2 3/29/12 102.34
Product Product Product Product
id version number price
2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51 Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id version index value
1 2 0 2
1 2 1 3
•
audit repo mode
•
classic
•
always writes complete list
•
range-based
Choose the Right
DBStore Mapping!
Order Order Order Orderid version date sum
1 2 3/29/12 102.34
Product Product Product Product
id version number price
2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51
•
audit repo mode
•
classic
•
always writes complete list
•
range-based
•
writes deltas
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_Listid from to index value
1 1 null 0 2 1 1 1 1 4 1 2 null 1 3 1 1 1 2 3
Choose the Right
DBStore Mapping!
•
branching repo mode
•
classic vs. range-based
•
copy-lazy (default) vs. copy-on-branch
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3
Choose the Right
DBStore Mapping!
•
branching repo mode
•
classic vs. range-based
•
copy-lazy (default) vs. copy-on-branch
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
Choose the Right
DBStore Mapping!
•
branching repo mode
•
classic vs. range-based
•
copy-lazy (default) vs. copy-on-branch
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
Choose the Right
DBStore Mapping!
•
branching repo mode
•
classic vs. range-based
•
copy-lazy (default) vs. copy-on-branch
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3
Choose the Right
DBStore Mapping!
•
branching repo mode
•
classic vs. range-based
•
copy-lazy (default) vs. copy-on-branch
Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List Order_Product_List
id branch from to index value
1 2 1 null 0 2 1 2 1 null 1 5 1 2 1 null 2 4
Choose the Right
DBStore Mapping!
2.250 4.500 6.750 9.000 721 1.491 1.481 688 4.581 1.473 1.483 736 8.941 1.506 1.442 681time to insert 100 objects at beginning
time to insert 100 objects in the middle
time to insert 100 objects at the end
App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
Choose the Right
Transport Layer!
CDO Client CDO Server CDO Client CDO Server Computer 1 Computer 2TCP (true client/server)
TCP (same computer)
Choose the Right
Transport Layer!
CDO Client CDO Server CDO Client CDO Server Computer 1 Computer 2TCP (true client/server)
TCP (same computer)
A Word On
Caching
•
Revision Caches in CDO
use Soft references
•
Caches grow until memory
limit is reached
•
View Cache can be
configured to use strong or
weak references instead
CDO
Client
CDO
Server
View Cache (Soft Ref) Session Cache (Soft Ref) Repository Cache (Soft Ref)App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
Choose the Right
Model Configuration!
Native Reflective Legacy 11.302 8.882 8.581time to read 100,000 objects
4.460 3.076
2.802
App
Logic
CDO
Client
EMF
Model
CDO
Server
IStore
Code
Storage
Make Use of
CDO Loading Policies!
•
Lazy Collection Loading
session.options().setCollectionLoadingPolicy( CDOUtil.createCollectionLoadingPolicy(
/* initial = */ 5, /* onResolve = */ 5));
•
Explicit Prefetching
CDOObject fromCDO = getMyObjectFromCDO(); fromCDO.cdoPrefetch(/* depth = */ 3);
•
Prefetching by Policy
Leftovers
•
Things I did not talk about
•
unordered collections
•
store queries (use with caution!)
Summary
•
Choose the Right Storage!•
Choose the Right Database!•
Choose the Right Repository Mode!•
Choose the Right DBStore Mapping!•
Choose the Right Transport Layer!•
Choose the Right Model Configuration!•
Make Use of CDO Loading Policies!