RubyConf 2014 - Day 2
by
Keynote - Sandi Metz - MADAM SANDI TELLS YOUR FUTURE
- Matz is nice and so we are nice (minaswan)
- Scroll -3000 to 0
- Romans - Codex (books) - random access. read and write at the same time
- Scriptorium - snarky comments -
- 0 to 1400 - written by hand
- 1450 - gutenberg
- yak shaving - letter print (swort?) - wear out quickly
- need reliable way to copy sworts
- lost the rights
- print shops
- upper case and lower case
- stereotypes - whole pages cast instead of just the individual letters
- still set by hand. newspapers have to do it every day
- 18x linotype
- dynamicly cast a whole line of type
- machine to create lines of type, molds lead after lining up
- edison called 8th wonder of the world
- newspapers 8 to 48 pages per issue
- newspapers actively recruited deaf employees
- never complain about CSS again
- worldwide literacy
- hot to cold type
- the fortune : everything will change
- death, decay, obscelence
- the ‘happy path’ of life
- MVP - health, happyness
- contribute
- do for others
- always something that needs doing
Fringe Ruby - 2 + CATS = 4 * CUTE: HOW MATH WORKS IN RUBY - Chris Hoffman - @yarmiganosca - Optoro
- numerical coercion
-
#coerce(numeric) -> array
- find a common type between the two operands1.2.coerce(3) => [3.0, 1.2]
- Vectors - can we make these work with coerce?
- yes, define coerce and operation(s)
- Dimensional analysis
- gem unitary
- size * dimension
- Other uses
- currency manipulation (gem conversions)
- balance chemical equations?
- function scaling/composition
Fringe Ruby - A PARTIAL-MULTIVERSE MODEL OF TIME TRAVEL FOR DEBUGGING - Brock Wilcox
- pry-byebug (2.0+)
- YARV bytecode
- trace codes - hooks into VM state
- pry-timetravel
-
back
to step backwards into previous state
-
- every next, fork and suspend the fork
- back, grab most recent child fork
- pid = fork
- if pid parent; else child
- $$ = current pid
- signals (OS Callbacks)
Signal.trap
Process.kill
- SIGTSTP - SIGSTOP (uncatchable) - no io, etc, -> SIGCONT (continue, unstop)
- limitations
- can only go back as far as snapshots
- shared file handles, incl sockets
- threads :-( - no copy of threads
- memory exhaustion
- complication
- shell detects stop, inside
- fix : make dummy parent process
- killing parent processes
- fix : kill the others
- except everything will have this, so force?
Kernel.exit!
- zombies
- child exited, but parent doesnt waitpid - process is dead, yet remains
- owned by init
- shell detects stop, inside
- snapshot tree?
- can back to pid
- ‘snap $cmd’
- autosnapshot and prune
- autosnap every stack frame change
- other techniques
- yarv - keep track of everything there
- ocaml debugger does fork()
- “why is reverse debugging rarely used” on stackexchange
- elm-lang, watches what is changed
JRuby 9000 - Charles Nutter @headius & Tom Enebo @tom_enebo
- Ruby on JVM
- native threads, tooling, JIT
- pull in any java library, ehcache, neo4j, lucene
- other languages, scala, jython, clojure, groovy
- JRuby 1.7 == Ruby 1.8 or 1.9 - new releases frequently
- JRuby 9 == Ruby 2.2(+) - release mid Jan?
- New runtime
- Major IO & Encoding
- timing
- startup time (from command line)
- warmup time (until best performance)
- running time (now running)
- indy (invoke dynamic) - high warmup time, lower stable time
- MRI - internal representation -> interpreter
- Jruby - internal representation -> (interpreter) -> java bytecode -> native code
- why not JIT everything? cause warmup is slow.
- JIT creates lots of classes
- more code for the JVM to deal with
- benchmarking
- benchmark/ips or perfer
- with warmup/rehearsal time
- jvm and jruby are mixed mode - interpreter -> JIT
- example
- deoptimization (undo optimizations) to try crazy optimizations and rollback if it doesnt work
- Jruby –dev (skip jit) faster warmup for dev
- Drip - new jvm for next command, like spring preloader
- tell what to preboot, gets faster
- New runtime (IR)
- no AST, semantic representation
- traditional compiler design
- no heap allocated arguments, removes extra binding
- add jruby –debug
- compiler optimizations (dead code, constant propogation, inlining, unboxing) - done with pluggable compiler passes
- new IO and character Transcoding (M17n)
- MRI gives thin wrapper around fd
- JVM gives Channel, which looks like fd
- old Jruby emulates libc fd
- JDK uses UTF16
- impossible to emulate some POSIX stuff
- new IO layer (OpenFile) - passes nearly all, performance better, match MRI
- Old JIT
- 16k loc just for bytecode gen
- one-off optimizations
- New JIT
- 95% done
- 56k loc
- equal performance, lots of room to improve
- Memory Analysis + debugging
- VisualVM. GC, java object level
- Ruby-centric version
- Alienist - java -> ruby heap dump
- mri version?
- size, query language?
- allow implementation specific data
- spec for json format
- TODOs
- finish JIT
- AOT compiler (jrubyc)
- IR compile & interp speedups
- Refinements
- MRI test suite
- How to help
- run master - jruby-head (in travisci)
- openjdk8 oraclejdk8 openjdk7
- rbenv/ruby-build jruby-9(.0.0.0)-dev
- setup for dev - clone; mvn -Pbootstrap;
- run tests/specs, find excluded that is fixed
- fork, create a branch, send a PR
- implement tagged/excluded
- mine for bugs (Beginner tags)
Elixr
- Thread - lots of ways to shoot self in foot
- Built on Erland VM - Erricson labs - telephone switch
- Not just a CoffeeScript for Erlang
- better tools, syntax, standardlib
- Tools
- iex (REPL) - built in doc system, in markdown
- mix (project mgr, create project, manage dependencies, run tests)
- pipe operator
- data transformations - (nested fns)
- Actor concurrency model
- “Process”
- performs one task
- send and receipt messages, messages are pattern matched to methods
- unshared memory
- Ackermann function
- unprocessed messages are buffered (queued)
- Fault tolerance
- supervision tree. supervisors are just processes
- can restart processes, kill them off etc
- keep calm and let it crash
- supervisor heirarchy can take over and put system back together
- http load tester example
- coordinator, create workers, track responses
- workers just send message back with result
- task is like a future/promise
- runs in a container. await to gather result
- distributed
- message passing between processes on network are transparent
- Phoenix Framework
MY LITTLE C EXTENSION: LEGO ROBOTS ARE MAGIC - Brandon Hays
- about burnout
- how to C in ruby
- start a gem, good guide on rubygems
- include ruby.h
- include c dependencies
- magic Init_native to define module, method(s)
- cast C types to Ruby types
- (VALUE self) - own ruby object
- segfaults (yay)
- wrap the rest of the API
- Style Guide
- Keep low level like C (ugly)
- Low level wrappers in a ::Native module
- prefix c method helpers
- C Ext Cheat sheets (links in slides)
- atone for cheating :-)
- oh no, people are using it
- how did it help burnout?
- just doing something for self
- play to get <3 back
- play is how you realize unlimited potential