Skip to content

Instantly share code, notes, and snippets.

@gdiggs
Created June 5, 2011 13:43
Show Gist options
  • Save gdiggs/1008971 to your computer and use it in GitHub Desktop.
Save gdiggs/1008971 to your computer and use it in GitHub Desktop.
GoRuCo2011 Notes

GoRuCo 2011 | Gordon Diggs

Ryan Smith (@ryandotsmith)

  • Gene Amdahl's Law
  • How to improve concurrency
    • Removing FIFO
      • FIFO isn't really needed a lot of the time in a queue of jobs
        • can ditch FIFO if order of jobs doesn't matter
        • if order matters, have a job fire things that depend on it at completion
      • fuzzy-FIFO
        • have many head nodes with a top boundary
        • worker can take job from any head node above top boundary
      • lock_head() (PL/pgSQL) EXECUTE 'SELECT id FROM' || ' jobs' || ' WHERE locked_at IS NULL' || ' ORDER BY id ASC' || ' LIMIT 1' || ' OFFSET' || relative_top || ' FOR UPDATE' || ' NOWAIT' INTO locked;
        • do this procedure with a spin lock
        • skip lock ?
      • MVCC
    • Relax constraints
  • github.com/ryandotsmith/queue_classic
    • dependencies
      1. pg gem
      2. json
    • faster b/c it doesn't make a lot of object

Sandi Metz (@sandimetz)

  • Code needs to work today just once, and be easy to change forever
  • The purpose of design is to reduce the cost of change
  • Simple ways to judge the goodness of code
    • Transparent - the consesquences of change are visible and predictable
    • Reasonalbe - the cost of adding a new feature is proportional to its value
    • Usable - if you wrote it, you can reuse it
    • Exemplary - More code like this would be good for your app
  • Code will never be done, just need to know when to stop
  • Slides: less-goruco.heroku.com
  • Don't guess what changes will come, just guess what will change.
  • Let objects stand free

Paul Dix (@pauldix)

  • redis is single-threaded
  • redis.pipelined
  • ZeroMQ

Casey Rosenthal (@caseyrosenthal)

Jeremy Ashkenas

  • TextMate bundle to compile/run coffeescript
  • altjs.org

Mat Brown (@0utoftime) & John Crepezzi (@seejohnrun)

  • SQL Operators
    • Bulk inserts incredibly faster than regular inserts
    • HAVING count(1) > 1
    • Pagination
      • SELECT SQL_CALC_FOUND ROWS * FROM people WHERE face = 'awesome' LIMIT 10 OFFSET 20;
      • SELECT FOUND_ROWS();
  • slim_scrooge github.com/sdskyes/slim_scrooge
    • Learns to select only what's necessary
    • Uses a lot of memory for bigger apps
  • String Operators: strlen, left, right, concat, reverse
  • DB regex: SELECT 'John' REGEXP '^[a-zA-Z]+$';
  • Think about setting max lengths for fields - could save a lot of space at scale
  • validates_uniqueness_of doesn't work.
    • :unique is property of index, not column
  • github.com/seejohnrun/database_validation
  • ENUMs - kind of like validates_inclusion_of
    • pg adapter doesn't absoultely support - but gems exist to do so
  • Single Table Inheritance
    • if subclasses differ only in behavior, ok
    • otherwise, use Class-Table Inheritance
      • Superclass table stores common attributes
      • Not supported by ActiveRecord

Evan Phoenix (@evanphx)

githits.me/NewYorkCity

Lua

@mrb
Copy link

mrb commented Jun 5, 2011

NIce Gordon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment