Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
dev_size = 2048 * 1024 * 1024 # 1T
block_size = 2048 * 1
nr_blocks = dev_size / block_size
io_size = 128
#----------------------------------------------------------------
def calc_cows(n, nr_blocks)
#ifndef CONTAINER_H
#define CONTAINER_H
/*----------------------------------------------------------------*/
struct container;
/*
* The container presents a 64bit address space. The client decides where
* data goes in this address space. This address space is virtual and
@jthornber
jthornber / dm-thin-script.c
Created July 7, 2017 13:34
Example code for the little stack engine
#ifndef THIN_SCRIPT_PROGRAM_H
#define THIN_SCRIPT_PROGRAM_H
static struct instruction provision_code[] = {
{i_quiesce},
{i_alloc_block},
{i_dup, {.u = 1}},
{i_cmp, {.u = 0}},
{i_branch_if, {.u = 100}},
{i_dup, {.u = 1}},
def mk_hash(multiplier, shift, nr_buckets):
def hash(n):
h1 = (n * multiplier) >> (2 + shift)
h2 = h1 >> shift
return (h1 ^ h2) % nr_buckets
return hash
def run_test(hash_fn, nr_buckets, stride):