FORTH-ICS

Transactional Contention Management
as a Non-Clairvoyant Scheduling
Problem
[Attiya et al. PODC 06]
[Attiya and Milani OPODIS 09]
Alessia Milani
Optimism

Transactions (Txs) proceed until a conflict
occurs

T1 conflicts with an on-going T2 if T1 tries to write
to a data item previously accessed by T2
 one transaction aborts or waits for the other
to complete

If no conflict occurs, they run in parallel
Conservative approach

A conflict does not imply a violation of
serializability
T1
Read(X)0
Write((Z))
ABORT
Conflict
T2

Read(Y)
Write(X)1
COMMIT
T1 and T2 can both commit without violating
strict serializability
Contention manager mediates conflicts

Decides which transaction aborts

E.g., the Greedy contention manager
[Guerraoui et al. PODC 05]



Each Tx is assigned a unique timestamp
reflecting Txs real-time order
If Txs T1 and T2 conflict,
the Tx with the smaller timestamp aborts / waits
Decides when to restart aborted Txs

E.g., CAR-STM [Dolev et al. PODC 08]

the aborted Tx is not executed until the completion of
the conflicting Tx  unrelated Txs may be executed
serially
Need for a “clever” contention
manager

Complete the work quickly
 makespan : Worst-case total time to complete all
transactions

Not waste work
 do not repeate conflicts

What Works and Why?
What Works and Why? In Practice
[Scherer and Scott, CSJP 04]

Extensive testing






Backoff
Aging
Randomized
Various priority
…
None dominates on all benchmarks
What Works and Why? In Theory

Contention Management as a Scheduling
problem

Evaluate the throughput, measured by the
makespan of a finite set of transactions


Worst-case total time to complete all transactions
Relative to the makespan guaranteed by an
optimal off-line scheduler
Non-Clairvoyant Scheduling

A scheduler A does not know Txs characteristics
a priori


Evaluated in comparison with an optimal,
clairvoyant scheduler


Txs arrive one by one, and their duration is unknown
knows the set of Txs, their data set, their release
times and duration
Competitive ratio: max makespanA () makespanOPT ()

A lower bound for CM
[Attiya et al. PODC 06]
Theorem 1. The competitive ratio of any
work conserving CM is Ω(s)
It always lets a maximal set of
non-conflicting transactions run
Even if the contention manager is :

centralized
Lower Bound: Workload

The proof uses s2/2 transactions



s is the number of shared data items
Each transactions access two data items
All transactions



are available at time 0
have the same duration
may have a different data set if executed at
different times or restarted
Lower Bound: First Requests
Work conserving
CM must select
an independent
set of s Txs
E.g., column 1.
1
2
3
…
s/2
1
1
1
1
…
1
2
3
3
3
…
3
3
5
5
5
…
5

…
…
…
…

s/2
s-1
s-1
s-1
…
s-1
1
2
2
2
…
2
2
4
4
4
…
4
3
6
6
6
…
6

…
…
…
…

s/2
s
s
s
…
s
Lower Bound: Second Requests
Odd Txs all
ask for 2
Even Txs all
ask for 1
Only two Txs
can complete
1
2
3
…
s/2
1
1,2
1
1
…
1
2
3,2
3
3
…
3
3
5,2
5
5
…
5

…
…
…
…

s/2
s-1,2
s-1
s-1
…
s-1
1
2,1
2
2
…
2
2
4,1
4
4
…
4
3
6,1
6
6
…
6

…
…
…
…

s/2
s,1
s
s
…
s
Lower Bound: Next Set
Similarly…
Only two Txs
can complete
from the
second
independent
set of s Txs
1
2
3
…
s/2
1
1,2
1,4
1
…
1
2
3,2
3,4
3
…
3
3
5,2
5,4
5
…
5

…
…
…
…

s/2
s-1,2
s-1,4
s-1
…
s-1
1
2,1
2,3
2
…
2
2
4,1
4,3
4
…
4
3
6,1
6,3
6
…
6

…
…
…
…

s/2
s,1
s,3
2k
…
s
Lower Bound: Repeat
In general,
at most two Txs
from each
independent set
can complete
1
2
3
…
s/2
1
1,2
1,4
1,6
…
1,s
2
3,2
3,4
3,6
…
3,s
3
5,2
5,4
5,6
…
5,s

…
…
…
…

s/2
s-1,2
s-1,4
s-1,6
…
s-1,s
1
2,1
2,3
2,5
…
2,s-1
2
4,1
4,3
4,5
…
4,s-1
3
6,1
6,3
6,5
…
6,s-1

…
…
…
…

s/2
s,1
s,3
s,5
…
s,s-1
Makespan of Non-Clairvoyant
Scheduler
1
2
3
After aborting,
all Txs
request the
same data
item
Makespan ≈
2
s
2
s  s
…
s/2
1
1,2
1,4
1,6
…
1,s
2
3,2
3,4
3,6
…
3,s
3
5,2
5,4
5,6
…
5,s

…
…
…
…

s/2
s-1,2
s-1,4
s-1,6
…
s-1,s
1
2,1
2,3
2,5
…
2,s-1
2
4,1
4,3
4,5
…
4,s-1
3
6,1
6,3
6,5
…
6,s-1

…
…
…
…

s/2
s,1
s,3
s,5
…
s,s-1
Makespan of Clairvoyant Scheduler
Schedule an
extended
diagonal
together
s/2 independent
Txs complete
Makespan ≈ s
Competitive
ratio ≈ s
1
2
3
…
s/2
1
1,2
1,4
1,6
…
1,s
2
3,2
3,4
3,6
…
3,s
3
5,2
5,4
5,6
…
5,s

…
…
…
…

s/2
s-1,2
s-1,4
s-1,6
…
s-1,s
1
2,1
2,3
2,5
…
2,s-1
2
4,1
4,3
4,5
…
4,s-1
3
6,1
6,3
6,5
…
6,s-1

…
…
…
…

s/2
s,1
s,3
s,5
…
s,s-1
A matching Upper Bound
Theorem 2. Any work conserving CM with the
pending commit property has O(s) competitive
ratio
at any time, some running transaction
will execute uninterrupted until it commits

Proved for the Greedy CM [Attiya et al. PODC 06]

Relies on the fact that Txs write most of the time
Read-Dominated Workloads

Existing results hold for write-dominated workloads

Transactions need exclusive access for most of their
duration (early-write transactions)
[Guerraoui et al. PODC 05, Attiya et al. PODC 06]

What about read-dominated workloads?


[Attiya & Milani. OPODIS 09]
Read-only transactions
Late-write transactions
1
3
4
…
k
k+1
Extending the lower bound to readdominated workload
Theorem 3. There is a read-dominated workload, s.t.
the competitive ratio of any deterministic CM is Ω(s)


It holds also for CM that has a more careful
approach than being conservative
Transactions :


have the same duration, are available at time 0
But may have a different data set if executed at
different times or restarted
Lower Bound : Workload
1
2
…
q
R1 Rq Rq+1 Wq+1
2
R1 Rq Rq+2 Wq+2
R1 Rq Rq+2 Wq+2
…
R1 Rq Rq+2 Wq+2
…
…
R1 Rq Rq+i Wq+i
…
R1 Rq Rq+i Wq+i
…
…
R1 Rq Rq+i Wq+i
q
R1 Rq R2q W2q
R1 Rq R2q W2q
…
R1 Rq R2q W2q
1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
2
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
…
…
i
…
…
…
…
R1 Rq Rq+1 Wq+1
…
R1 Rq Rq+1 Wq+1
…
1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
m-q R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
Makespan of Non-Clairvoyant
Scheduler
Work
…
1
2
R1 Rq Rq+1 Wq+1
2
R1 Rq Rq+2 Wq+2
R1 Rq Rq+2 Wq+2
…
R1 Rq Rq+2 Wq+2
…
…
R1 Rq Rq+i Wq+i
…
…
R1 Rq Rq+i Wq+i
R1 Rq R2q W2q
R1 Rq R2q W2q
…
R1 Rq R2q W2q
q+1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q+ 2
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
…
e.g., 1 row
plus m-q
read-only
Txs
R1 Rq Rq+i Wq+i
…
i
…
…
…
…
R1 Rq Rq+1 Wq+1
…
R1 Rq Rq+1 Wq+1
…
1
…
conserving
CM must
select an
independent
set of m Txs
q
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q
m
Makespan of Non-Clairvoyant
Scheduler
Only
one Tx in
…
1
2
R1 Rq Rq+1 Wq+1
2
R1 Rq Rq+2 Wq+2
R1 Rq Rq+2 Wq+2
…
R1 Rq Rq+2 Wq+2
…
…
R1 Rq Rq+i Wq+i
…
R1 Rq Rq+i Wq+i
…
R1 Rq Rq+i Wq+i
…
i
…
…
…
…
R1 Rq Rq+1 Wq+1
…
R1 Rq Rq+1 Wq+1
…
1
…
Restarted Txs
all request the
same data
item
q
R1 Rq R2q W2q
R1 Rq R2q W2q
…
R1 Rq R2q W2q
q+1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q+ 2
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
…
a given row
can commit
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q
m
Makespan of Non-Clairvoyant
Scheduler
…
1
2
2
R1…Rq R1 W1
…
R1…Rq R1 W1
q
q+1
Makespan
s
2
q+ 2
…
q=s/2
 ( 1)  s
s
2
2
m
R1…Rq R1 W1
R1…Rq R1 W1
…
…
…
R1…Rq R1 W1
…
i
…
…
R1…Rq R1 W1
…
…
…
R1…Rq R1 W1
…
We have to
execute them
serially
1
…
At time q,
still  q2 latewrite Txs to
be executed
q
R1…Rq R1 W1
…
To remove the work-conserving …
assumption :
A Tx that starts after time q is [R1…Rq R1 W1]
…
…
Makespan of the Clairvoyant Scheduler
R1 Rq Rq+2 Wq+2
R1 Rq Rq+2 Wq+2
…
R1 Rq Rq+2 Wq+2
…
…
R1 Rq Rq+i Wq+i
…
R1 Rq Rq+i Wq+i
…
…
R1 Rq Rq+i Wq+i
…
…
2
…
R1 Rq Rq+1 Wq+1
…
…
R1 Rq R2q W2q
R1 Rq R2q W2q
…
R1 Rq R2q W2q
q+1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q+ 2
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
…
Competitive
ratio s
q
R1 Rq Rq+1 Wq+1
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
R1 R2 … Rq-1Rq
…
R1 R2 … Rq-1Rq
q
Makespan s
…
R1 Rq Rq+1 Wq+1
i
q=s/2
2
1
…
At time q, all Txs
are committed
1
…
Each column is
an independent
set of Txs
m
A lower bound for conservative CM
Theorem 4. There is a late-write workload,such that
the competitive ratio of any deterministic
conservative scheduler is Ω(m)

The makespan is not competitive even
relative to a clairvoyant online scheduler
[Dragojevic et al. PODC 09]

It has complete information on a transaction as it arrives
On Bimodal Workloads


If a transaction writes, it writes from the very
beginning
Recent contention managers try to avoid
repeated conflicts by serializing conflicting Txs


CAR-STM, Steal On Abort, ATS
They are conservative


Ω(m) competitive ratio for read-dominated workloads
(by Theorem 4)
also Ω(m) competitive ratio for bimodal workloads
CAR-STM scheduler
Conflict
Txs in execution
Enqueued Txs
T4
T1
T5
T2
T3
T6
T4
T5
T6
T2
T3
T5


Serialize the execution
of read-only Txs
T1 is a writing Tx
T2 and T3 and T5 are read-only Txs
Bimodal scheduler
Conflict
Txs in execution
T2
T1
T3
T5
T2
T3
T6
T5
T4
T5
T6
Enqueued Txs
T2
T3
T5
Read-only queue


T1 is a writing Tx
T2 and T3 and T5 are read-only Txs
Summary
WORKLOADS
WRITEDOMINATED
Early write
BIMODAL :
Early write +
read-only
READDOMINATED :
Late write +
read-only
1
“Conservative” schedulers
decrease performance
& 1 2 && 23  w/ read-dominated WL
late-write Txs are
Any scheduler
“Conservative” to
scheduler
more
handle
Can a difficult
“smarter” scheduler
than
read-only Txs
do better?
1
(s)
[Attiya et al.]
(s)
derived from
[Attiya et al.]
(s)
At what cost?
(m)
CAR-STM,
ATS, SoA
(m)
2
O(s)
Bimodal
O(m)
trivial
3