Skip to content

Instantly share code, notes, and snippets.

View mattsta's full-sized avatar
🐢
Moving slowly and fixing things

Matt Stancliff mattsta

🐢
Moving slowly and fixing things
View GitHub Profile
@mattsta
mattsta / redis-cluster-linux-bring-up
Last active August 29, 2015 13:57
Redis Cluster Linux Bring-Up
# Launch 18 redis cluster instances on one machine using two IPs
cd redis/src
for dir in {1..9}; do mkdir $dir; pushd $dir; rm -f *.conf *.rdb; ../redis-server --bind 127.0.0.1 --cluster-enabled yes --port 700$dir & popd; done
IP=`/sbin/ifconfig eth0 |grep "inet addr" | tail -1 |awk '{printf $2}' |awk -F: '{printf $2}'`
for dir in {21..29}; do mkdir $dir; pushd $dir; rm -f *.conf *.rdb; ../redis-server --bind $IP --cluster-enabled yes --port 70$dir & popd; done
./redis-trib.rb create --replicas 1 127.0.0.1:{7001..7009} $IP:{7021..7029}
@mattsta
mattsta / hmset.sh
Last active August 29, 2015 14:00
test a redis pathology with hmset
#!/bin/bash
ARGS="-c 10 -n 1"
PATH=~/repos/redis/src
redis-benchmark $ARGS eval '
for i=0,50000 do
local key = string.format("data/%019d/xxxxxxxxxxxxxxxxxx", i)
redis.call("HMSET", key, "AAAAAAAAAAA:current", "AA", "AAAAAAAAAAA:current-time", "Thu May 01 11:08:34 BST 2014", "AAAAAAAAAAA:target", "AA", "AAAAAAAAAAA:target-time", "Thu May 01 11:08:34 BST 2014", "aaaaaaaaaaaaaaaaaaaa:current", "aa", "aaaaaaaaaaaaaaaaaaaa:current-time", "Thu May 01 11:08:34 BST 2014", "aaaaaaaaaaaaaaaaaaaa:target", "aa", "aaaaaaaaaaaaaaaaaaaa:target-time", "Thu May 01 11:08:34 BST 2014", "bbbbb:current", "bbbbbbbbbbbbbbbbbbbbbbbbb", "bbbbb:current-time", "Thu May 01 11:08:34 BST 2014", "bbbbb:target", "bbbbbbbbbbbbbbbbbbbbbbbbb", "bbbbb:target-time", "Thu May 01 11:08:34 BST 2014", "cccccccccccccccccccccc:current", "cc", "cccccccccccccccccccccc:current-time", "Thu May 01 11:08:34 BST 2014", "cccccccccccccccccccccc:target", "cc", "cccccccccccccccccccccc:target-time", "Thu May 01 11:08:34 BST 2014", "ddddddddd
@mattsta
mattsta / bench.pl
Created June 22, 2014 05:41
Quick Redis speed comparison script
#!/usr/bin/perl
use warnings;
use strict;
use IO::All;
use IO::Socket::UNIX qw( SOCK_STREAM );
use Benchmark ':hireswallclock';
use Redis;
use RedisDB;
@mattsta
mattsta / size_parse.c
Created September 11, 2014 03:29
Quick redis integer size parsing tests
/* Usage: ./size_parse INTEGER [1-5] */
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
@mattsta
mattsta / clang-O0.s
Created September 16, 2014 21:30
Comparing geohash assembly output based on compiler optimization levels
.section __TEXT,__text,regular,pure_instructions
.section __DWARF,__debug_info,regular,debug
Lsection_info:
.section __DWARF,__debug_abbrev,regular,debug
Lsection_abbrev:
.section __DWARF,__debug_aranges,regular,debug
.section __DWARF,__debug_macinfo,regular,debug
.section __DWARF,__debug_line,regular,debug
Lsection_line:
.section __DWARF,__debug_loc,regular,debug
matt@ununoctium:/tmp% tar xfvzp redis-2.8.17.tar.gz
x redis-2.8.17/
x redis-2.8.17/build-static-symbols.tcl
x redis-2.8.17/generate-command-help.rb
x redis-2.8.17/hyperloglog/
x redis-2.8.17/hyperloglog/.gitignore
x redis-2.8.17/hyperloglog/hll-err.rb
x redis-2.8.17/hyperloglog/hll-gnuplot-graph.rb
x redis-2.8.17/install_server.sh
x redis-2.8.17/mkrelease.sh
@mattsta
mattsta / gist:7512d430b3cc43bd669e
Last active August 29, 2015 14:06
Because tired of anonymous process names
[Everything here is ps output captured by "ps auxww|grep [r]edis-"]
Master / Replica (no config specified on the master):
./redis-server /Users/matt/repos/redis/redis.conf *:9999 replica (connected to 127.0.0.1:6379)
./redis-server *:6379 master (1 replica)
Master with config file:
./redis-server /Users/matt/repos/redis/redis.conf *:6379 master (1 replica)
Same master as above, but with a name defined too (if name is set, name shows instead of config file path):
@mattsta
mattsta / nginx.config.nice
Last active August 29, 2015 14:07
hack at me, bro
/usr/local/src/web/nginx-1.7.6% cat config.nice
./configure --prefix=/sw --with-http_perl_module --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-pcre=../../libs/pcre-7.9/ --add-module=../nginx-upload-module/ --with-http_spdy_module --with-openssl=/usr/local/src/sys/openssl-1.0.1j
@mattsta
mattsta / redis-demo.service
Created October 21, 2014 21:20
redis systemd voodoo
[Unit]
Description=Redis Demo
After=network.target
[Service]
# Port 0 stops Redis from listening to ports by itself
ExecStart=/home/matt/repos/redis/src/redis-server --dir /tmp --port 0
PrivateTmp=yes
# Redis requires non-blocking sockets or else _nothing_ works
@mattsta
mattsta / mergables
Created October 29, 2014 20:52
things in my hidden merge branch
Author: Matt Stancliff <matt@genges.com>
Date: Mon Oct 20 13:07:06 2014 -0500
Add dynamic proctitle support
Uses new anet IP formatting to show proper IPv4 vs IPv6 results too.
Closes #2081
Author: Matt Stancliff <matt@genges.com>
Date: Mon Oct 20 10:39:11 2014 -0400