Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Unicorns Die With Bullets Made of Glitter

Vicent Martí
September 20, 2013

Unicorns Die With Bullets Made of Glitter

The reduced, 30 minutes version of this collection of Ruby Systems Horror Stories, including:

- Mark & Sweep, a tale of a dumb garbage collector
- Our Time is Running Out, a tale of tricky timeouts

Originally presented at Rubyfuza.

Vicent Martí

September 20, 2013
Tweet

More Decks by Vicent Martí

Other Decks in Programming

Transcript

  1. These are horror stories from the GitHub Systems team (the

    rainbows are just to make them less awful)
  2. Conservative Stop The World Mark and Sweep Garba e Collector

    Non-deterministic Basically a shitshow.
  3. Mark 1. Walk the object raph 2. Look for thin

    s that look like Ruby objects
  4. Ruby handles raw pointers to C extensions. The Garba e

    Collector must find roots in the stack, the heap and in re isters.
  5. Sweep 1. Go throu h every sin le object 2.

    Free the ones that have not been marked
  6. char * VALUE * … … RStrin MAGICAL RUBY THINGS

    int a_ruby_function(VALUE rb_foo) { char *str = RSTRING_PTR(rb_foo); return do_smthing(str); }
  7. char * VALUE * … … RStrin MAGICAL RUBY THINGS

    int a_ruby_function(VALUE rb_foo) { char *str = RSTRING_PTR(rb_foo); return do_smthing(str); } H e l l o W o r l d \0
  8. char * … … H e l l o W

    o r l d \0 int do_smthing(char *str) { /* do stuff */ return strlen(str); }
  9. int do_smthing(char *str) { /* do stuff */ return strlen(str);

    } Un ! Un ! Mark o throu h stack. Yes. Stack.
  10. Un ! This no look like Ruby object. Mark no

    touchie! char * … … … H e l l o W o r l d \0
  11. No root. H e l l o W o r

    l d \0 RStrin MAGICAL RUBY THINGS Strin object with no roots? Set fire. Yes. Fire.
  12. No root. H e l l o W o r

    l d \0 Strin object with no roots? Set fire. Yes. Fire.
  13. int do_smthing(char *str) { /* do stuff */ return strlen(str);

    } *sound of an explosion* “What was that?” “Dunno.”
  14. Bonus Points Use Val rind/ASan instead of tamperin . Your

    Rails test suite Heat death of the Universe
  15. MRI 1.8.7 Use si nals & the power of Unix

    MRI 1.9.3 Release the GVL
  16. (shut up, kid) You see, I was usin JRuby, and

    the GitHub API you uys keep breakin …