Stochastic Multi-CAS Filip Pizlo Purdue University Crazy Idea - - PowerPoint PPT Presentation

stochastic multi cas
SMART_READER_LITE
LIVE PREVIEW

Stochastic Multi-CAS Filip Pizlo Purdue University Crazy Idea - - PowerPoint PPT Presentation

Stochastic Multi-CAS Filip Pizlo Purdue University Crazy Idea Talk ISMM | 22 Oct 2007 | Montreal Compare and Swap If Target = Expected Value Then Target := New Value End Return Old Value Compare and Swap Compare and Swap (CAS) is


slide-1
SLIDE 1

Stochastic Multi-CAS

Filip Pizlo Purdue University

ISMM | 22 Oct 2007 | Montreal Crazy Idea Talk

slide-2
SLIDE 2

Compare and Swap

If Target = Expected Value Then Target := New Value End Return Old Value

slide-3
SLIDE 3

Compare and Swap

  • Compare and Swap (CAS) is

essential for implementing interesting lock-free algorithms.

  • But existing CAS

implementations are quite constrained...

slide-4
SLIDE 4

The Problem

  • Hardware gives at best a 128-

bit CAS. The bits must be contiguous in memory.

  • Lock-free software CAS

implementations can relax this constraint - but they do so by stealing bits.

slide-5
SLIDE 5
  • Lots of algorithms can be

easily made lock-free if we had practical multi-CAS.

  • Example: concurrent GC.
  • But bit stealing is

intrusive.

Why should you care?

slide-6
SLIDE 6
  • Stealing a bit is intrusive

because:

  • vanilla C/C#/Java primitive

types

  • we require that the client

software be designed with an a priori knowledge about bit stealing.

slide-7
SLIDE 7

Harris approach

slide-8
SLIDE 8

Harris approach

Hardware CAS-able word

slide-9
SLIDE 9

Harris approach

Hardware CAS-able word Steal one bit

slide-10
SLIDE 10

Harris approach

Hardware CAS-able word Steal one bit Either payload

  • or-

CASN control data

slide-11
SLIDE 11

Can we get 1 bit without stealing it?

slide-12
SLIDE 12

Is there some way to cheat?

slide-13
SLIDE 13

Yes!

slide-14
SLIDE 14

Use a random number!

slide-15
SLIDE 15

Stochastic approach

slide-16
SLIDE 16

Stochastic approach

Hardware CAS-able word

slide-17
SLIDE 17

Stochastic approach

Hardware CAS-able word All bits available

slide-18
SLIDE 18

Stochastic approach

Hardware CAS-able word When it comes to run multi-CAS, store random marker. !@#$%^&*&*$&^!^&$&%$^

slide-19
SLIDE 19

Stochastic approach

Hardware CAS-able word !@#$%^&*&*$&^!^&$&%$^ When marker present, use remaining bits for multi-CAS control data.

slide-20
SLIDE 20

Why is it good?

  • Can multi-CAS any field

(including primitive fields)

  • The types don’t need to

change

  • Lock-free, performance need

not be atrocious.

slide-21
SLIDE 21

What is the challenge?

  • Convincing people to use a

stochastic algorithm.

slide-22
SLIDE 22

Conclusion

  • An implementation already

exists: http://homepage.mac.com/pizlo/smcas

slide-23
SLIDE 23

Conclusion

  • An implementation already

exists: http://homepage.mac.com/pizlo/smcas CAS throughput: 92ns/64bit!

slide-24
SLIDE 24

Conclusion

  • An implementation already

exists: http://homepage.mac.com/pizlo/smcas CAS throughput: 92ns/64bit! (Upper bounds. It’s faster per-field for larger Multi-CAS operations.)

slide-25
SLIDE 25

Conclusion

  • An implementation already

exists: http://homepage.mac.com/pizlo/smcas CAS throughput: 92ns/64bit! (Upper bounds. It’s faster per-field for larger Multi-CAS operations.) Read barrier throughput: ~2ns/64bit!