technology from seed exploiting off-the-shelf virtual memory mechanisms to boost software...

23
technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João Barreto Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham Email: [email protected] id.pt

Upload: janel-kelly

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Amin Mohtasham, Paulo Ferreira and João Barreto

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Email: [email protected]

Page 2: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Multicore revolution

• Chip-multiprocessors are mainstream hardware

• We must effectively program these systems

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory January 22nd, 2014

Page 3: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Lock-based methods

Parallel Programming with traditional locks is difficult

There is a trade-off between complexity and performance

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory January 22nd, 2014

Page 4: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Software Transactional Memory

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

• Software Transactional Memory is:– Easy to use

– Portable

– Not limited by hardware capacity

Page 5: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

The dark side of STM

STM has more sequential overhead than HTM

How can we alleviate this overhead?

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Page 6: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

A typical STM read operation

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Physical Memory

Thread#1

X=10

readTx(X)

read(X)

if isConsistent() then

here comes the overhead

Page 7: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Our objective

• Most transactional workloads are Read-Dominated

• Most of the read operations are consistent– Validation is a waste of work for consistent reads

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Can we actually read directly from memory and avoid the validation?

Page 8: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

A naïve approach: Direct read operations

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Physical Memory

Thread#1

X=10

read(X)

Thread#2

write(X)

read(X)

TX1

TX2

TX3

Is there any safe way to read directly from memory?

Inconsistent X=99

Page 9: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

An interrupt by hardware!

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Process

Virtual Memory

• MMU is a common component of commodity hardware

• By relying on the page-level mechanisms in MMU, we can prevent threads from accessing a memory page

Amin Mohtasham

Page 10: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

A more sophisticated approach:Using page protection bits

Page TablePhysical Memory

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

PageBaseAddress Read Write

0x2FF8000 1 1

Thread#2Thread#1

write(X)

read(X)

TX1

TX2

0 0

read(X)

blockedblocked

0x2FF8000 X=10X=99

For a given page, how can we give different permissions to different threads?

Page 11: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Mapped memory

• By using memory map functions, we can define different virtual memory regions with different protection levels

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Page TablePhysical Memory

PageBaseAddress Read Write

0x2FF8000

0x2FF8000

0x2FF8000

0 0

1 1

Thread#1 Thread#2

read(X)

read(X)

X=10

[Abadi et al., ACM PPOPP’09]

Page 12: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Proof of concept: PGSTM

• At most, one writer transaction at each time– Using a single global lock

• Multiple read-only transactions can at each time

• Read-only transactions can execute in parallel, as long as they do not read from pages being written

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Page 13: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

PGSTM’s Memory Model

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Page Table Physical Memory

Shared Data

Read-only region

Read/Write region

• Two different virtual memory regions pointed at same physical memory pages

• Read-only Region contains either read-only or inaccessible pages• In Read/Write region all pages are accessible and updatable

Page 14: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

PGSTM in action

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Page TablePhysical Memory PageBaseAddress Read Write

0x2FF8000 1 1

0x2FF8000 X=10

Thread#2Thread#1

write(X)

read(X)

TX1

TX2

read(X)

0x2FF8000 1 1

0 0

blockedX=99

Page 15: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

When to unlock a page?

• Can we unlock the page when the writer commits?– It is not safe if there are other active read-only

transactions running

• Unlock only after such active transactions complete

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Page 16: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Evaluation environment

• List look-up benchmark

• Read-only transactions search for a random element

• Read/Write transactions modify a random element

• We compare our results with TML [Dalessandro et al.,Europar’10]

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Page 17: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

TML: Transactional Mutex Locks

• At most, one writer transaction at each time– Using a single global lock

• Read-only transactions can not run in parallel with the writer transaction

• With the lowest sequential overhead

Amin MohtashamExploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Page 18: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Evaluation: Different contentions

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Throughput for different contention levels[64 threads, 10% write-load]

Amin Mohtasham

Less contention

Page 19: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Evaluation: Scalability

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Throughput for different number of concurrent threads[2MB List, 10% write-load]

Amin Mohtasham

Page 20: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Evaluation: Different write loads

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Throughput for different write loads [2MB List, 64 threads]

Amin Mohtasham

Page 21: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Conclusion

• Using MMU with STMs can lower their sequential overhead

• We proposed PGTSM as proof of concept

• PGSTM outperforms TML in low contention scenarios

• Our preliminary results are promising

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Page 22: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Future works

• Evaluating with non-trivial benchmarks

• Supporting multiple writers

• Using finer grained conflict detection

• Upgrading to a generic accelerator layer that runs on top of any STM

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham

Page 23: Technology from seed Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory Amin Mohtasham, Paulo Ferreira and João

technologyfrom seed

Exploiting Off-the-Shelf Virtual Memory Mechanisms to Boost Software Transactional Memory

Thank you!

Amin Mohtasham