On UnQLite

21
On UnQLite Kenichi Ishigaki (@charsbar) Kyoto.pm #5 Jul 13, 2013

description

Presented at Kyoto.pm Tech Talk #5

Transcript of On UnQLite

Page 1: On UnQLite

On UnQLite

Kenichi Ishigaki

(@charsbar)Kyoto.pm #5Jul 13, 2013

Page 2: On UnQLite

http://blog.64p.org/entry/2013/07/05/155212

Page 3: On UnQLite

UnQLite = Not SQLite

Page 4: On UnQLite

What's Different

• Key/Value Store• Document Store

(JSON)• License (2-Clause

BSD)

Page 5: On UnQLite

What's Similar

• Self-contained• Cross Platform

Page 6: On UnQLite

Suitable For Toolchains

Page 7: On UnQLite

Usage: Like A Hash

tie my %hash, 'UnQLite', 'foo.db';$hash{foo} = 'bar';print $hash{foo};

Page 8: On UnQLite

Usage: OOPs

my $db = UnQLite->open('foo.db');$db->kv_store(foo => 'bar');my $v = $db->kv_fetch('foo');

Page 9: On UnQLite

Usage: Iterationmy $db = UnQLite->open('foo.db');my $cursor = $db->cursor_init;while($cursor->next_entry && $cursor->valid_entry) { my ($key, $data) = ($cursor->key, $cursor->data); ...}

Page 10: On UnQLite

JSON... only for Jx9

my $db = UnQLite->open(':memory:');$db->exec(<<'JX9');db_exists('foo') || db_create('foo');db_store('foo', [{bar: 'baz'}]) || print db_errlog();print db_fetch('foo');# {"bar":"baz","__id":0}JX9say dump $db->kv_fetch('foo'); # ?????

Page 11: On UnQLite

Performance

Page 12: On UnQLite

$ perl bench.pl --perl --bdb --sqlite 100 10000 (store) Rate sql bdb_hs bdb_bt unq kc unq_m perlsql 23.5/s -- -10% -19% -22% -41% -80% -86%bdb_hs 26.1/s 11% -- -10% -13% -35% -78% -85%bdb_bt 29.0/s 23% 11% -- -4% -28% -75% -83%unq 30.1/s 28% 15% 4% -- -25% -74% -83%kc 40.2/s 71% 54% 39% 33% -- -66% -77%unq_m 118/s 400% 351% 306% 291% 193% -- -32%perl 172/s 633% 560% 495% 472% 329% 47% --

Page 13: On UnQLite

$ perl bench.pl --perl --bdb --sqlite 10 100000 (store) Rate bdb_hs sql unq bdb_bt kc perl unq_mbdb_hs 1.14/s -- -53% -57% -60% -81% -89% -89%sql 2.43/s 114% -- -8% -15% -59% -76% -77%unq 2.65/s 133% 9% -- -7% -55% -74% -75%bdb_bt 2.87/s 152% 18% 8% -- -52% -72% -73%kc 5.95/s 424% 145% 124% 108% -- -42% -44%perl 10.2/s 798% 320% 285% 256% 71% -- -4%unq_m 10.6/s 836% 338% 301% 271% 79% 4% --

Page 14: On UnQLite

$ perl bench.pl --perl --bdb --sqlite 10 1000000 (store) s/iter bdb_hs unq sql bdb_bt unq_m kc perlbdb_hs 10.7 -- -32% -61% -65% -81% -83% -87%unq 7.29 47% -- -43% -49% -72% -76% -81%sql 4.17 158% 75% -- -10% -51% -57% -67%bdb_bt 3.74 187% 95% 12% -- -45% -52% -63%unq_m 2.04 426% 257% 104% 83% -- -13% -32%kc 1.78 502% 309% 134% 110% 14% -- -22%perl 1.40 669% 423% 199% 168% 46% 28% --

Page 15: On UnQLite

$ perl bench.pl --perl --bdb --sqlite 10 10000000 (store) s/iter unq_m bdb_hs unq kc sql bdb_bt perlunq_m 184 -- -38% -51% -67% -77% -78% -91%bdb_hs 114 62% -- -20% -46% -62% -64% -85%unq 91.0 103% 25% -- -33% -53% -55% -82%kc 61.3 201% 86% 48% -- -30% -33% -73%sql 43.1 328% 164% 111% 42% -- -5% -61%bdb_bt 40.9 350% 178% 122% 50% 5% -- -59%perl 16.6 1008% 584% 447% 268% 159% 146% --

Page 16: On UnQLite

$ perl bench.pl --bdb 100 10000 (fetch) Rate bdb_bt unq bdb_hs kcbdb_bt 40.0/s -- -5% -8% -23%unq 42.2/s 5% -- -3% -19%bdb_hs 43.7/s 9% 3% -- -16%kc 52.1/s 30% 23% 19% --

Page 17: On UnQLite

$ perl bench.pl --bdb 10 100000 (fetch) Rate bdb_hs bdb_bt unq kcbdb_hs 2.21/s -- -39% -43% -59%bdb_bt 3.60/s 63% -- -7% -33%unq 3.88/s 76% 8% -- -28%kc 5.41/s 145% 50% 39% --

Page 18: On UnQLite

$ perl bench.pl --bdb 10 1000000 (fetch) s/iter bdb_hs unq bdb_bt kcbdb_hs 4.94 -- -26% -40% -61%unq 3.67 35% -- -19% -48%bdb_bt 2.97 67% 24% -- -35%kc 1.92 158% 92% 55% --

Page 19: On UnQLite

$ perl bench.pl --bdb 10 10000000 s/iter bdb_hs unq kc bdb_btbdb_hs 53.2 -- -15% -20% -37%unq 45.0 18% -- -6% -26%kc 42.5 25% 6% -- -22%bdb_bt 33.3 60% 35% 28% --

Page 20: On UnQLite

New storage engines are coming

soon(?)

Page 21: On UnQLite

Further Information

http://unqlite.orghttps://github.com/tokuhirom/UnQLite