Skip to content

Instantly share code, notes, and snippets.

View russelldb's full-sized avatar

Russell Brown russelldb

View GitHub Profile
@russelldb
russelldb / gist:7596268
Created November 22, 2013 07:39
riak-erlang-client counter usage
1> {ok, Pid} = riakc_pb_socket:start_link("localhost", 8087).
{ok,<0.35.0>}
2> riakc_pb_socket:set_bucket(Pid, <<"foo">>, [{allow_mult, true}]).
ok
3> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, 1).
ok
4> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, 3).
ok
5> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, -2).
ok
@russelldb
russelldb / sitrep.md
Created September 13, 2013 16:09 — forked from pozorvlak/sitrep.md

Here's where I understand the state of the art to be:

  • In this INRIA tech report, Shapiro, Preguiça, Baquero and Zawirski (SPBZ) prove, amongst other things, that a sufficient condition for CRDTs to achieve eventual consistency on networks which may reorder and duplicate packets (which I'll call flaky networks, henceforth) is that
    1. the underlying datatype forms a semilattice,
    2. messages are full states,
    3. incoming messages are combined with the node's current state using the least-upper-bound operation in the semilattice.
  • It's possible to relax condition 2 and still achieve eventual consistency over flaky networks by fragmenting the state into independent parts and transmitting updates to each part separately. For instance, in the G-Set CRDT (an add-only bitset) one can transmit only the index of the element to be added.
  • In [these slides from a talk at Dagstuhl](http://www.dagstuhl.de/mat/Files/13/13081/13081.BaqueroCarlos.Sl
@russelldb
russelldb / crdt.md
Created September 9, 2013 08:03 — forked from pozorvlak/crdt.md

CvRDTs are (almost?) as general as they can be

What are you talking about, and why should I care?

Now that we live in the Big Data, Web 3.14159 era, lots of people want to build databases that are too big to fit on a single machine. But there's a problem in the form of the CAP theorem, which states that if your network ever partitions (a machine goes down, or part of the network loses its connection to the rest) then you can keep consistency (all machines return the same answer to

@russelldb
russelldb / gist:6368223
Created August 28, 2013 16:44
What should happen? Looks correct, but weird, no?
{set,{var,1},{call,crdt_statem_eqc,create,[riak_dt_multi]}},
{set,{var,2},
{call,crdt_statem_eqc,merge,[riak_dt_multi,{0,{var,1}},{0,{var,1}}]}},
{set,{var,3},
{call,crdt_statem_eqc,merge,[riak_dt_multi,{0,{var,2}},{0,{var,2}}]}},
{set,{var,4},
{call,crdt_statem_eqc,update,
[riak_dt_multi,
{update,[{update,{<<>>,riak_dt_vvorset},{add_all,[]}}]},
{0,{var,3}}]}},
Node 'riak@127.0.0.1' not responding to pings.
bad -z option -zdss
Usage: beam.smp [flags] [ -- [init_args] ]
The flags are:
-a size suggested stack size in kilo words for threads
in the async-thread pool, valid range is [16-8192]
-A number set number of threads in async thread pool,
valid range is [0-1024]
-B[c|d|i] c to have Ctrl-c interrupt the Erlang shell,
@russelldb
russelldb / pr.md
Created September 20, 2012 08:35 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@russelldb
russelldb / gist:3524264
Created August 30, 2012 08:38
Macbbook Air 10.7.4 1.8ghz intel i7
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> erlang:system_info(cpu_topology).
undefined
2>
@russelldb
russelldb / xeon_6_core
Created August 30, 2012 08:36
Intel® Xeon® Six Core E5-2620 (2.0 GHz, 7.20 GT/s, 15M L3 Cache)
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:12:12] [rq:12] [async-threads:0] [kernel-poll:false]
Eshell V5.8.5 (abort with ^G)
1> erlang:system_info(cpu_topology).
[{processor,[{core,[{thread,{logical,0}},
{thread,{logical,6}}]},
{core,[{thread,{logical,1}},{thread,{logical,7}}]},
{core,[{thread,{logical,2}},{thread,{logical,8}}]},
{core,[{thread,{logical,3}},{thread,{logical,9}}]},
{core,[{thread,{logical,4}},{thread,{logical,10}}]},
@russelldb
russelldb / core_2_quad
Created August 30, 2012 08:33
Intel Core 2 Quad Q8300 LGA775 'Yorkfield' 2.5GHz 4MB-cache (1333FSB) Processor
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> erlang:system_info(cpu_topology).
[{processor,[{core,{logical,0}},
{core,{logical,1}},
{core,{logical,2}},
{core,{logical,3}}]}]
2>
@russelldb
russelldb / gist:3380399
Created August 17, 2012 16:30 — forked from argv0/gist:3372596
Getting detailed per-request timing in Riak
(riak@127.0.0.1)1> {ok, C} = riak:local_client().
{ok,{riak_client,'riak@127.0.0.1',undefined}}
(riak@127.0.0.1)2> Object = riak_object:new(<<"testbucket">>, <<"testkey">>, <<"testvalue">>).
{r_object,<<"testbucket">>,<<"testkey">>,
[{r_content,{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],[],...}}},
<<"testvalue">>}],
[],
{dict,1,16,16,8,80,48,