Ruby in the Fast Lane
James Edward Gray II (works on “Scout” at his job)
Created the Ruby Quiz at the beginning but don’t do it anymore
Evil rumor “Ruby is Slow”
James says it is “BS”..
Ruby goes as fast as we want it to.
Tools to speed up:
NArray, SQLite, RBTree, FSDB, Rinda, and most important tool: “Thinking out of the box”
Numeric Array … very fast..
Ruby’s numbers were built for “easy of use” but sometimes this makes it slower
C’s numbers were built for speed
Ruby can borrow C’s numbers in NArray…
Example Problem: Faster imaging
1.3 seconds to create 400 by 200 image using 2d array
changing to NArray made it less than a 1/100 of a second..
sqlite has already solved many hard problems for data storage
It gives you an entire language to express your data needs…
IP to country
code: require: open-uri, zlib, rubygems, faster_csv, sqlite3
sqlite3 has a lot of cool features including unicode support
db = SQLite3::Database.new(<name of file)
sqlite can use named parameter
SQlite is totally free…
Can receive results as a hash…
Can work with in memory databases ( this is crazy fast)
You can run queries across multiple database files
You can define SQL functions in pure RUBY code!
a binary tree
RBTree is super efficent…
Real binary search..
drops search below 1/1,000ths of a second
Ruby SortedSet gets 15 times faster if RBTree is loaded…
FSDb – filesystem as a has
not a gem… but can be found on sourceforge
Relational databases do not use times series data at all..
The has is a path in a file system…
db = FSDB::Database.new(“server_stats/”)
DB[time.strftime(“%Y/%m/%d/%H/%M.obj”)] = data…
Very simple to use… makes getting data very easily…
Can define your own format for files…
dirt simple inter-process communication (IPC)
don’t have to install it…comes with Ruby
example problem: take a scramble word and find what it could be.
Create a “signature” by sorting the letters alphabetically… just need to find matching signatures.. just takes time to find it then..
Creates tuple space:
results = Rinda:TupleSpace.new
RingServer — zero config networking..
q: url for slides
a: not online yet, but will be put online… there will be a file server that is put up for the conference