stochastic multi cas
play

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


  1. Stochastic Multi-CAS Filip Pizlo Purdue University Crazy Idea Talk ISMM | 22 Oct 2007 | Montreal

  2. Compare and Swap If Target = Expected Value Then Target := New Value End Return Old Value

  3. Compare and Swap • Compare and Swap (CAS) is essential for implementing interesting lock-free algorithms. • But existing CAS implementations are quite constrained...

  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.

  5. Why should you care? • Lots of algorithms can be easily made lock-free if we had practical multi-CAS. • Example: concurrent GC. • But bit stealing is intrusive.

  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.

  7. Harris approach

  8. Harris approach Hardware CAS-able word

  9. Harris approach Hardware CAS-able word Steal one bit

  10. Harris approach Hardware CAS-able word Either payload Steal one bit -or- CASN control data

  11. Can we get 1 bit without stealing it?

  12. Is there some way to cheat?

  13. Yes!

  14. Use a random number!

  15. Stochastic approach

  16. Stochastic approach Hardware CAS-able word

  17. Stochastic approach Hardware CAS-able word All bits available

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

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

  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.

  21. What is the challenge? • Convincing people to use a stochastic algorithm.

  22. Conclusion • An implementation already exists: http://homepage.mac.com/pizlo/smcas

  23. Conclusion • An implementation already exists: http://homepage.mac.com/pizlo/smcas CAS throughput: 92ns/64bit!

  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.)

  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!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend