Title: Increasing Concurrency in Databases using Program Analysis
1Increasing Concurrency in Databases using Program
Analysis
- Roman Vitenberg, Kristian Kvilekval and Ambuj
Singh
- University of California, Santa Barbara
2Outline
- Motivation
- Shape graphs and prediction
- Predictive scheduler optimizations
- Results
- Conclusions
3Transactional Schedulers
- Most fundamental problem of concurrency control
Pap86BHG87
- Little has been done on predictive schedulers
- Difficult to extract future usage
- Difficult to use it (Optimal Scheduling
NP-complete)
4Program analysis for better concurrency
- OODBs increasingly integrated (JDO)
- Shape analysis makes predicting data accesses
more feasible
- Transactional code is known in advance
- Rich type structure available to analysis
- Enhance schedulers with specific optimizations
based on the extracted info
- Deadlock handling, early lock release, adaptive
preclaiming
5Previous and Related Work
- Scheduling in object bases
- GrahamBarker95
- Shape analysis (pointer analysis)
- Escape analysisBogda99Ruf00
- ParallelizationCorbera99
- Type SafetyGhiya96 Nurit98 Wilhem00
- Others...
6Outline
- Motivation
- Shape graphs and prediction
- Predictive scheduler optimizations
- Results
- Conclusions
7Overview of Prediction
- Predict locking based on program code
- Extract program summary in shape graph
- Provide runtime system with future accesses
- Advantages
- Facilitates integration OODB
- Supports complex pointer-based structures
- Automatically derived from source code
8Example shape
class Connector Part a,b class Part Con
nector left,right,up,down Material m Suppli
er s int volume() weight0 while
(part) weight(part.material.density
part.volume()) partpart.right.b
9Basic Shape Analysis
- Graph
- Abstract locations (heap cells)
- Edges labeled with with field names
- Abstract interpretation
- Extend graph through field references
- Combine graphs when heap location is shared
- Merge shapes bottom up through static call graph
10Predicting with shape graphs
- Compile Time
- Generate shapes for method references
- Self, arguments, and global variables
- Label shape edges with earliest access
- Annotate programs to pass visible references and
shapes to transaction scheduler
- Runtime
- Interpret shape graph on the actual object graph
generating expected object set
11Predicting with Shape Graphs
Object Graph
N5
a1
N
N
o10
o45
o610
J10
F10
F
J
J
o210
o515
a2
a4
K
G5
K10
o320
a5
a3
Shape Graph
(o1,a1) (o4,a1) (o2,a2) (o6,a1) (o5,a4)
(o3,a5)
12Outline
- Motivation
- Shape graphs and prediction
- Predictive scheduler optimizations
- Results
- Conclusions
13Deadlock Handling Background
- Deadlock detection
- Wait-for-graph (WFG)
- Nodes are active transactions
- Edge (ti,tj) indicates that ti waits for tj to
release a lock
- Maintaining throughout execution is expensive
- Deadlock prevention
- Heuristic-based techniques (wound-wait)
- Cheaper but causing unnecessary transaction
aborts
- Resource allocation graph (infeasible w/o future
knowledge)
14Deadlock handling our approach
- Shape analysis helps us prune parts of WFG and
other graphs in all graph-based algorithms
15Early lock release background
- Strict 2PL all locks are held till the end of
transaction
- Non-strict 2PL read locks are released after the
last access to the object
- Non-strict allows greater concurrency but
- Difficult to determine the last access
- Allows non-serializable execution
16Early lock release non-searializable execution
T1 Acq(o1) T2 read(o1) Rel (o1)
Acq(o1) write(o1) Acq(o2) write(
o2) Rel(o1,o2) Acq(o2) read(o2) Rel
(o2)
17Early lock release our approach
- Estimate the last access to an object in order to
release early
- Causality-aware scheduler
- T1 causally precedes T2 (T1 ?c T2) if either
- T2 is initiated after T1 by the same client, or
- T2 acquires a lock that T1 has released, or
- There is T3 such that T1 ?c T3 and T3 ?c T2
- If T1 ?c T2 the scheduler blocks T2.A(O) if T1
may access O in the future.
18Early lock release Causality-aware scheduling
T1 Acq(o1) T2 read(o1) Rel (o1)
Acq(o1) write(o1) Acq(o2) locks write(o2) Rel(o1,o2) Acq(o2)
read(o2) Rel(o2)
19Lock preclaiming background
- Standard 2PL acquires locks gradually
- Conservative 2PL preclaims all the locks
- Fewer aborts upon high contention long
transactions
- Shorter wait-for chains
- T1.A(O2)
- T2.A(O1)T2.A(O2)
- T3.A(O1)
- Requires apriori knowledge of locks
20Lock preclaiming our approach
- Predict the set of objects to be preclaimed
automatically
- Adaptive hybrid schemes
- Preclaim when expected contention level is high
across executing transactions
- Preclaim locks only for short transaction
21Outline
- Motivation
- Shape graphs and prediction
- Predictive scheduler optimizations
- Results
- Conclusions
22Overview of performance measurements
- Two applications OO7 Prototype reservation
system
- Mix of transaction types (lock sequence,
short/long transactions)
- Transaction rates, and transaction parameters
- Compare Standard 2PL with our enhanced 2PL based
on scheduling delay time
23Evaluation OO7
- Short Read
- 2ms
- 600/min
- Short Update
- 2ms
- 10/min
- Long Reorg
- 2000ms
- 3/min
Comp Parts
24OO7 Results
Relative delay by scheduler
25Delays in short query
Predictive
Strict 2-Phase
26Conclusions future directions
- Runtime use of shape graph can generate object
use prediction (even without prior statistics)
- Transaction scheduler improved by
- Better deadlock handling (smaller WFG)
- Early read lock release
- Lock preclaiming
- Future lease prediction
27End
28Evaluation Car Reservation
29Evaluation car reservation
Query
Traversal
Starved
Starved
30Construction of Shape Graphs
x
31Construction of Shape Graphs
x.f s
F
32Construction of Shape Graphs
x.f s t x.f.g
F
G
33Construction of Shape Graphs
x.f s x.f.g t x x.n
N
F
?
G
34Construction of Shape Graphs
x.f s x.f.g t if (x ! null) x x.n
35Combining Shape Graphs
x y
36Combining Shape Graphs
37Unification of Shape Graphs
N
F
J
G
K
38Shape Analysis Algorithm
- ? methods Interpret basic blocks
- Create shapes for basic blocks
- Run until fixed-point is reached
- Propagate in static callgraph
39Static Call Graphs
main
Static representation of calls
m2
m3
m4
m3 a.f s o.m4(a) Class C m4(F f)
Unify(a,f)
f
40Call Graphs
m1
- Propagate bottom up
- Merge polymorphic calls
- Recursive Calls
- Fixed point
- Merge SCCRuf00
m2
B.m4
m3
m4
D1.m4
D2.m4
m1
m2
m1
41Overview of scheduler enhancements
- Better Deadlock handling
- Smaller WFG based on type information
- Conservative Resource Allocation Graph
- Early Lock Release
- Read locks released after last use
- Lock Preclaiming
- Better throughput in high contention