Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Core Unleashed Part II: Introduction to GobiesVM (and STM) @ RubyKaigi 2014

Core Unleashed Part II: Introduction to GobiesVM (and STM) @ RubyKaigi 2014

Szu-Kai Hsu (brucehsu)

September 18, 2014
Tweet

More Decks by Szu-Kai Hsu (brucehsu)

Other Decks in Programming

Transcript

  1. Locks are bad “Beautiful Concurrency”, Simon Peyton Jones (2007) Taking

    too few locks Taking too many locks Taking the wrong locks Taking locks in the wrong order Error recovery Lost wake-ups and erroneous retries
  2. GobiesVM in a nutshell Written in Go, utilizing native data

    structures and GC A Ruby subset derived from tinyrb Therefore uses a LEG parser instead of bison Stack-based VM which resembles YARV Minimal modification to existing code
  3. VM Coroutine Coroutine Coroutine Coroutine Transaction Transaction Transaction Transaction Transaction

    Transaction Transaction Transaction Transaction Transaction Transaction Transaction
  4. BC_GETLOCAL, i BC_SEND, +, 1 BC_PUTOBJ, 1 BC_SEND BC_GETLOCAL Begin

    End Transaction bytecode stack ivar object-set rev
  5. Transactional Locking II Global Timestamp Transaction Transaction Local Timestamp Local

    Timestamp Read Set Read Set Write Set Write Set Transaction Local Timestamp Read Set Write Set
  6. Speculative Execution (READ) a Read Set Write Set a b

    c d e 0x5566 0x5567 0x5568 0x5569 0x5570 0x5566 10
  7. Speculative Execution (WRITE) a+=1 Read Set Write Set a b

    c d e 0x5566 0x5567 0x5568 0x5569 0x5570 0x5566 a 11 10 0x5566
  8. Speculative Execution (READ-AFTER-WRITE) a Read Set Write Set a b

    c d e 0x5566 0x5567 0x5568 0x5569 0x5570 0x5566 a 11
  9. Validation Read Set Write Set Global Timestamp Check rev of

    object rev > local_timestamp: object has been modified Acquire locks of objects to be modified Abort on failure Increments by one
  10. Better parser Go provides goyacc for parsing But we have

    to do lexical scanning ourselves. https://sourcegraph.com/blog/multi-language-lexer- and-scanner-for-go
  11. Better syntax support What we don’t have now: Conditional statements

    Class/Method definitions Double-quoted strings And more…
  12. Production-ready (perhaps) Rubygems Native extension interface Go can work with

    C code, but not thread-safe Comprehensive exceptions