Skip to content

Instantly share code, notes, and snippets.

Rick Branson rbranson

Block or report user

Report or block rbranson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:007f989da12ba912ae7ec5859d4d732a
Schema
==========================================
CREATE TABLE locks (
name VARCHAR(191) PRIMARY KEY,
clock BIGINT
);
CREATE TABLE ledger (
seq BIGINT AUTO_INCREMENT PRIMARY KEY,
View unsafe.go
package stupid
import (
"fmt"
"reflect"
"unsafe"
)
type iptr struct {
@rbranson
rbranson / interface_slice.go
Created Apr 26, 2018
I'm not advocating this particularly idea.
View interface_slice.go
// Converts args to an interface slice using the following rules:
//
// - Returns empty slice if no args are passed
//
// - For a single argument which is of a slice type, the slice
// is converted and returned.
//
// - For a single argument which is not a slice type, the value is
// returned within a single-element slice.
//
View my-favorite-outage.md

The other story begins with adding a C library extension to the monolith. This was some Python code that wrapped a C library which gave access to an internal data store. Unfortunately, the bindings had a bug in their string handling code. To get a string object that could be sent to the Python C APIs, it used a family of functions called PyString_FromString.

The developer writing these C bindings didn’t realize that strings are immutable in Python, and the C API documentation for strings doesn’t include that bit of information. To copy a string from the C world to Python-land, the bindings would first use this function to initialize a Python string to use as a buffer. It would fill said buffer with the string from the C side by poking at the object’s internal data structures. This did actually work, as it was never seen BEFORE it was filled nor was it modified AFTER it was sent across the wall to Python-land.

Then disaster struck. A configuration change caused the it-has-always-worked function to begin t

@rbranson
rbranson / intbloat-ca-cert-test.js
Created Feb 22, 2017
Demonstrates additional memory / CPU usage when forcing use of the OS-provided root certificates
View intbloat-ca-cert-test.js
// run this in bash with 'time' and it'll show CPU usage totals at the end
var totalCycles = 250;
var concurrencyLevel = 25;
var useOSCerts = true;
var requestOptions = {
hostname: 'www.google.com',
port: 443,
path: '/',
View transactions.csv
client_id operation key value
0 BEGIN
1 BEGIN
0 READ 100
0 COMMIT
0 BEGIN
1 READ 100
0 WRITE 100 0
0 READ 100
1 COMMIT
View leaving-hound.md

Hey friends,

I wanted to let you know what's up with myself and Hound. I have left the company. There were fundamental conflicts among the founding team that were not reconcilable in any timeframe that would have made sense for an early-stage company.

Though it has certainly been a painful process, I still think the world of my co-founders, Charity and Christine. These are two immensely capable, hard-working, and genuinely caring people. I give my highest recommendation to anyone who would consider working with them in the future.

As for myself, I'll be spending the next few months spending time with friends and family as well as working on some side projects.

~ Rick

View foo.go
type Q interface {
Hello() string
}
type A struct {
}
func (x *A) Hello() {
return "Hello!"
}
@rbranson
rbranson / gist:038afa9ad7af3693efd0
Last active Sep 29, 2016
Disaggregated Proxy & Storage Nodes
View gist:038afa9ad7af3693efd0

The point of this is to use cheap machines with small/slow storage to coordinate client requests while dedicating the machines with the big and fast storage to doing what they do best. I found that request coordination was contributing to about half the CPU usage on our Cassandra nodes, on average. Solid state storage is quite expensive, nearly doubling the cost of typical hardware. It also means that if people have control over hardware placement within the network, they can place proxy nodes closer to the client without impacting their storage footprint or fault tolerance characteristics.

This is accomplished in Cassandra by passing the -Dcassandra.join_ring=false option when the process is started. These nodes will connect to the seeds, cache the gossip data, load the schema, and begin listening for client requests. Messages like "/x.x.x.x is now UP!" will appear on the other nodes.

There are also some more practical benefits to this. Handling client requests caused us to push the NewSize of the heap up

View gist:2ffe33c09b2f4116d245
In [2]: os.path.join(["foo", "bar"])
Out[2]: ['foo', 'bar']
In [3]:
In [3]: os.path.join("foo", "bar")
Out[3]: 'foo/bar'
You can’t perform that action at this time.