Skip to content

Instantly share code, notes, and snippets.

@dspezia
dspezia / gist:967358
Created May 11, 2011 21:06
Patch to fix redis 2.2-jemalloc branch
From 6094d46541b1fd66c65954b611e8b7e7a6cd7665 Mon Sep 17 00:00:00 2001
From: Didier Spezia <didier.06@gmail.com>
Date: Wed, 11 May 2011 22:53:41 +0200
Subject: [PATCH] Fix makefile for tcmalloc/jemalloc
---
src/Makefile | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/src/Makefile b/src/Makefile
@dspezia
dspezia / gist:993738
Created May 26, 2011 18:36
Example of pipelining with async hiredis
/* Code borrowed from hiredis examples */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/ae.h"
@dspezia
dspezia / gist:1240427
Created September 25, 2011 09:42
Instrumenting Redis to evaluate the efficiency of COW
/*
This function makes use of /proc to evaluate the ratio between shared and private memory blocks.
It is expressed as a percentage: 90 means 90% of the blocks are shared, and 10% have been duplicated.
Call this function at the very end of the child process.
For Redis, it is supposed to be called at the end of rdbSave (file rdb.c)
Ugly but effective.
Please note it does not work if huge pages are used
*/
@dspezia
dspezia / gist:1240452
Created September 25, 2011 10:21
Compiling Redis against libhugetlbfs to activate huge pages support
Redis can be compiled against libhugetlbfs, so huge pages support can be activated with Linux >= 2.6.16.
It should cover Enterprise Linux distros such as SLES 10 or better, and RHEL/Centos/OEL 5 or better.
Be sure to read http://lwn.net/Articles/374424/ first.
Install libhugetlbfs source code in local directory $DIRHUGE
Source can be downloaded from http://libhugetlbfs.sourceforge.net/
Compile only the 64 bits version using make BUILDTYPE=NATIVEONLY
The library will be generated in $DIRHUGE/obj64 - add it in your LD_LIBRARY_PATH
@dspezia
dspezia / gist:1272254
Created October 8, 2011 12:59
Benchmark huge pages
Host
====
Physical machine
2 * Intel X5670 @ 2.93 GHz, HT activated, 24 threads, cpufreq deactivated
48 GB
OS: SLES10 SP3
Linux ncegcolnx243 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux
@dspezia
dspezia / gist:1272522
Created October 8, 2011 16:43
Redis benchmark program for huge pages testing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "hiredis.h"
#define CHECK(X) if ( !X || X->type == REDIS_REPLY_ERROR ) { printf("Error\n"); exit(-1); }
@dspezia
dspezia / gist:1364675
Created November 14, 2011 18:20
Benchmark Redis 2.4.2 on Xeon 5670
Intel(R) Xeon(R) CPU X5670 @ 2.93GHz
Redis 2.4.2, unix domain sockets
numactl -C 2 src/redis-server redis.conf
ncegcolnx243:src> numactl -C 6 ./redis-benchmark -q -n 100000 -s /tmp/redis.sock
PING (inline): 200000.00 requests per second
PING: 201207.23 requests per second
MSET (10 keys): 93283.58 requests per second
SET: 202020.20 requests per second
@dspezia
dspezia / gist:1373801
Created November 17, 2011 17:17
AWKward script to get Redis keys and values
redis-cli keys "*" > keys.txt
cat keys.txt | awk '{ printf "type %s\n", $1 }' | redis-cli > types.txt
paste -d'|' keys.txt types.txt | awk -F\| '
$2 == "string" { printf "echo \"KEY %s %s\"\nget %s\n", $1, $2, $1 }
$2 == "list" || $2 == "set" { printf "echo \"KEY %s %s\"\nsort %s by nosort\n", $1, $2, $1 }
$2 == "hash" { printf "echo \"KEY %s %s\"\nhgetall %s\n", $1, $2, $1 }
$2 == "zset" { printf "echo \"KEY %s %s\"\nzrange %s 0 -1 withscores\n", $1, $2,$1 }
' | redis-cli
@dspezia
dspezia / 1 GigE
Created November 22, 2011 17:01
Benchmark Redis 2.4.3 comparing various object sizes
ncegcolnx243:src> numactl -C 4 redis-benchmark -q -n 100000 -d 100 -h ncegcolnx242
PING (inline): 134048.27 requests per second
PING: 132978.73 requests per second
SET: 131926.12 requests per second
GET: 129701.68 requests per second
INCR: 132275.14 requests per second
LPUSH: 132450.33 requests per second
LPOP: 130039.02 requests per second
SADD: 132978.73 requests per second
SPOP: 132978.73 requests per second
@dspezia
dspezia / tst.cpp
Created December 10, 2011 12:45
Variadic rpush C++ hiredis example
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include <hiredis.h>
using namespace std;