Skip to content

Instantly share code, notes, and snippets.

View michael-grunder's full-sized avatar
💭
Testing in production

Michael Grunder michael-grunder

💭
Testing in production
View GitHub Profile
@michael-grunder
michael-grunder / phpredis-subscribe.c
Created September 9, 2012 20:38
Different way of detecting callback
PHPAPI void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub_cmd)
zval *object, *array, **data;
HashTable *arr_hash;
HashPosition pointer;
RedisSock *redis_sock;
char *cmd = "", *old_cmd = NULL;
int cmd_len, array_count;
zval *z_tab, **tmp;
char *type_response;
@michael-grunder
michael-grunder / bigkeys (new)
Created February 27, 2014 19:28
redis-cli --bigkeys (new)
➜ src git:(cli_improved_bigkeys) ✗ time ./redis-cli --bigkeys
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest hash found so far '530f8e1db5876:1:hash:146377' with 44 fields
[00.00%] Biggest list found so far '530f8ed14a8b0:17:list:269378' with 193 items
[00.00%] Biggest set found so far '530f8da537194:83:set:63043' with 432 members
[00.00%] Biggest string found so far '530f8f2de7045:95:string:333887' with 345 bytes
@michael-grunder
michael-grunder / --bigkeys (old)
Created February 27, 2014 19:29
redis-cli --bigkeys (old)
➜ src git:(cli_improved_bigkeys) ✗ time redis-cli --bigkeys
# Press ctrl+c when you have had enough of it... :)
# You can use -i 0.1 to sleep 0.1 sec per 100 SCANS
# in order to reduce server load (usually not needed).
Biggest hash found so far '530f8e1db5876:1:hash:146377' with 44 fields.
Biggest list found so far '530f8ed14a8b0:17:list:269378' with 193 items.
Biggest set found so far '530f8da537194:83:set:63043' with 432 members.
Biggest string found so far '530f8f2de7045:95:string:333887' with 345 bytes.
<?php
ini_set('memory_limit','4G');
$arr_args = getopt('', Array('file:', 'port:', 'step:', 'runs', 'name:'));
if(!isset($arr_args['file'])) {
die("Please pass an input filename of sets!\n");
}
if(!isset($arr_args['port'])) {
die("Pass a port where redis-server is running!\n");
@michael-grunder
michael-grunder / gist:25960ce1508396d0d36a
Created July 11, 2014 20:01
OBJECT assertion in cluster
=== REDIS BUG REPORT START: Cut & paste starting from here ===
2100:M 11 Jul 12:18:14.922 # === ASSERTION FAILED ===
2100:M 11 Jul 12:18:14.922 # ==> db.c:987 'j < argc' is not true
2100:M 11 Jul 12:18:14.922 # (forcing SIGSEGV to print the bug report.)
2100:M 11 Jul 12:18:14.922 # Redis 2.9.999 crashed by signal: 11
2100:M 11 Jul 12:18:14.922 # Failed assertion: j < argc (db.c:987)
2100:M 11 Jul 12:18:14.922 # --- STACK TRACE
0 redis-server 0x000000010fc94f37 logStackTrace + 103
1 redis-server 0x000000010fc9410f _redisAssert + 159
2 libsystem_platform.dylib 0x00007fff824fb5aa _sigtramp + 26
include "hiredis.h"
#include <time.h>
/* Contrived arguments */
const char* argv[] = { "ZUNIONSTORE", "out-set", "5", "one", "two", "three", "four", "five"};
const size_t argvlen[] = {11, 6, 1, 3, 3, 5, 4, 4};
const int argc = 8;
/* Runs to perform */
const int N = 1000000;
Filter card Set count ZINTERUNION ZFILTERSTORE
1000 10 0.015698 0.002793
2000 10 0.019613 0.005862
3000 10 0.033271 0.010839
4000 10 0.043977 0.013726
5000 10 0.060546 0.014633
6000 10 0.065888 0.018436
7000 10 0.089333 0.025404
8000 10 0.101332 0.030149
9000 10 0.122370 0.025990
@michael-grunder
michael-grunder / gist:63e0f9eb924443c8ba3c
Last active August 29, 2015 14:08
silly dictNextPower test
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <math.h>
#define DICT_HT_INITIAL_SIZE 4
static unsigned long _dictNextPowerNew(unsigned long size)
{
➜ test clang -O2 -o pow2 pow2.c
➜ test ./pow2 36000000
1000000 => old=0.015580; new=0.008266 [new faster by 0.007314]
1500000 => old=0.018460; new=0.011828 [new faster by 0.006632]
2000000 => old=0.027408; new=0.016054 [new faster by 0.011354]
2500000 => old=0.027412; new=0.024791 [new faster by 0.002621]
3000000 => old=0.036629; new=0.024436 [new faster by 0.012193]
3500000 => old=0.048103; new=0.032976 [new faster by 0.015127]
4000000 => old=0.049787; new=0.037055 [new faster by 0.012732]
4500000 => old=0.065063; new=0.044097 [new faster by 0.020966]
@michael-grunder
michael-grunder / gist:4bf697a1378d5a83cc20
Last active August 29, 2015 14:08
CentOS -- Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz
[top-secret@top-secret test]# cc -O2 pow2.c -o pow2
[top-secret@top-secret test]# ./pow2 36000000
1000000 => old=0.000000; new=0.010000 [old faster by 0.010000]
1500000 => old=0.020000; new=0.010000 [new faster by 0.010000]
2000000 => old=0.020000; new=0.010000 [new faster by 0.010000]
2500000 => old=0.030000; new=0.020000 [new faster by 0.010000]
3000000 => old=0.030000; new=0.030000 [old faster by 0.000000]
3500000 => old=0.030000; new=0.030000 [old faster by 0.000000]
4000000 => old=0.050000; new=0.030000 [new faster by 0.020000]
4500000 => old=0.050000; new=0.030000 [new faster by 0.020000]