on the cost of concurrency in transactional memory

22
On the COST of concurrency In Transactional Memory Petr Kuznetsov TU Berlin/DT-Labs Joint work with Srivatsan Ravi Euro-TM, 2011

Upload: iman

Post on 05-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

On the COST of concurrency In Transactional Memory. Petr Kuznetsov TU Berlin/DT-Labs Joint work with Srivatsan Ravi. Euro-TM, 2011. STM is about ease-of-programming and efficient use of concurrency. Does it come with a cost?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: On the COST of concurrency In Transactional Memory

On the COST of concurrencyIn Transactional Memory

Petr KuznetsovTU Berlin/DT-Labs

Joint work with Srivatsan Ravi

Euro-TM, 2011

Page 2: On the COST of concurrency In Transactional Memory

STM is about ease-of-programmingand efficient use of concurrency

Does it come with a cost?

Page 3: On the COST of concurrency In Transactional Memory

3

Ease-of-programming: transactions with all-or-nothing semanticsOpacity: total order on transactions, including

aborted ones, every read returns the last committed value

Concurrency: running multiple transactions in parallelWhen a transaction must commit?

Page 4: On the COST of concurrency In Transactional Memory

4

Progress conditions: when to commit?

Single-lock: if no overlap with another transactionZero concurrency

Progressiveness: if no overlap with a conflicting transactionSome concurrency

Permissiveness: whenever possible (without affecting correctness)Maximal (?) concurrency

Page 5: On the COST of concurrency In Transactional Memory

5

How to measure the cost of concurrency?

The number of expensive synchronization patterns [Attiya et al., POPL 2011] :Read-after-write (RAW)Atomic-write-after-read (AWAR)

Page 6: On the COST of concurrency In Transactional Memory

6

Our results

In every permissive STMs, a transaction performs Ω(k) RAW/AWAR patterns for a read set of size k

There exist progressive STMs that incur at most one RAW or AWAR per transaction

Page 7: On the COST of concurrency In Transactional Memory

7

7

... write(X,1) read(Y) ...

...read(Y)...write(X,1)...

In almost all modern architectures

Read-after write reordering

Read-after write reordering

Read-after-Write: imposing order in relaxed memory models

In the code

Page 8: On the COST of concurrency In Transactional Memory

8

Enforcing the order read-after-write (RAW) fence

... write(X,1)

fence() // enforce the order read(Y) ...

Page 9: On the COST of concurrency In Transactional Memory

9

Enforcing the order atomic-write-after-read (AWAR)

E.g., CAS, TAS, fetch&add,…

atomic{

read(Y)... write(X,1)

}

Page 10: On the COST of concurrency In Transactional Memory

10

Why care about RAW/AWARs?

One RAW fences/AWAR takes ~50 RMRs!

But [Attiya et al., POPL 2011] any implementation that exports strongly non-commutative methods must use RAW/AWARs

Queues, counters, sets,…Mutual exclusion

… and transactions in STMs

Page 11: On the COST of concurrency In Transactional Memory

11

Non-commutative transactions

T1 influences T2 and T2 influences T1 => T1 must write to some base object x … and then read from some y≠x (or AWAR is performed)

At least one RAW/AWAR is used in T1

T1

W(Y,1)

R(Y)W(X,1)

R(X)T2

TryC

TryC

Page 12: On the COST of concurrency In Transactional Memory

12

In single-lock STMs, every reading and updating committed transaction performs at least one

RAW/AWAR

Extends to progressive and permissive STMs

Page 13: On the COST of concurrency In Transactional Memory

13

Permissive STMs

[R(Xm)] and [W(Xm);TryC] are strongly non-commutative => T3 enforces R(Xm) to perform a RAW/AWAR=> T1 performs Ω(m) RAW/AWARs

T1 R(X2)R(X1)

W(X1)

R(X1)

T3

T2

... R(Xm)

TryC

TryCW(Xm)

Page 14: On the COST of concurrency In Transactional Memory

14

In permissive STMs, a transaction performs at least one RAW/AWAR per read

What about weaker progress conditions?

Page 15: On the COST of concurrency In Transactional Memory

15

What about progressiveness?

Constant (multi) RAW/AWAR implementations:

1. Multi-trylocks: acquire a lock on a set of objects using one multi-RAW

2. mCAS: atomically verify the read-set and update the write set using at most one AWAR

No RAW/AWAR in read-only or aborted transactions

Page 16: On the COST of concurrency In Transactional Memory

16

Protected data Intuition: at some moment, every transaction

must protect all objects in its write set E.g., by acquiring locks or using time-outs

In every progressive disjoint-access-parallel STM, each transaction has to protect Ω(k) objects for a write set of size k

Page 17: On the COST of concurrency In Transactional Memory

17

SummaryTrade-offs between the degree of concurrency and

the cost of implementation Linear RAW/AWAR complexity for permissive

STMs Constant RAW/AWAR complexity for progressive

STMs (optimal)Extends to strong progressiveness

But even a progressive STM requires to protect a linear number of objects (e.g., acquire a linear number of locks)

Page 18: On the COST of concurrency In Transactional Memory

18

Future challenges

Exploring the space of progress conditionsObstruction-freedom, …

Relaxing opacity View transactions, elastic transactions, virtual world

consistency, snapshot isolation, etc. Refining the notion of protected data

More in TR, CoRR, http://arxiv.org/abs/1103.1302, 2011

Page 19: On the COST of concurrency In Transactional Memory

19

THANK YOU!

QUESTIONS?

Page 20: On the COST of concurrency In Transactional Memory

20

What’s wrong with reordering?

Process P:

...

write(X,1)

read(Y)

...

Process Q:

...

write(Y,1)

read(X)

...

P

QW(Y,1)

R(Y)W(X,1)

R(X)

W(X,1)

Page 21: On the COST of concurrency In Transactional Memory

21

Possible outcomes

P Q

P reads before Q writes

P reads after Q writes

Q reads after P writes

Q reads before P writes

Out-of-order: both think they run solo

Page 22: On the COST of concurrency In Transactional Memory

22 22

... write A read B ...

read Bwrite A

In almost all modern architectures

Read-after write reordering

Read-after write reordering

... write A fence read B ...

RAW fence: enforce orderRAW fence:

enforce order

Read-after-Write: imposing order in relaxed memory models