Skip to content

Instantly share code, notes, and snippets.

View antirez's full-sized avatar

Salvatore Sanfilippo antirez

View GitHub Profile

Redis 4.2 roadmap

  1. Redis Cluster
  • Speed up key -> hashslot association. Now makes RBB loading 4x slower when there are many small keys.
  • Better multi data center story
  • redis-trib C coded and moved into redis-cli
  • Backup / Restore of Cluster
  • Non blocking MIGRATE (also consider not using 2X memory)
  • Faster resharding
  • Bug fixing and stress testing to bring it to next level of maturity

Listpack specification

Version 1.0, 1 Feb 2017: Intial specification.

Version 1.1, 2 Feb 2017: Integer encoding simplified. Appendix A added.

Version 1.2, 3 Feb 2017: Better specify the meaning of the num-elements
                         field with value of 65535. The two 12 bits

positive/negative integers encodings were

require 'redis'
Chars=('A'..'Z').to_a
def g(prefix)
choice = rand(9)
if (choice == 0)
# Values around this size stress the cascading update.
len = [252,250].shuffle.first
prefix += rand(1000000).to_s
string = prefix + ("A"*(len-prefix.length))
/* gcc ziplist-stresstest.c zmalloc.c ziplist.c util.c sha1.c sds.c -Wall -W -O2 -o zl-test -ggdb -g; ./zl-test.
*
* To run with gcov use -Wall on OSX use -fprofile-arcs -ftest-coverage. */
#include "ziplist.h"
#include "util.h"
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
redis_version:2.4.13
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.1.2
process_id:3751
uptime_in_seconds:95986904
uptime_in_days:1110
lru_clock:1439339
23697:C 20 Dec 08:39:49.630 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23697:C 20 Dec 08:39:49.631 # Redis version=999.999.999, bits=64, commit=074383f8, modified=1, pid=23697, just started
23697:C 20 Dec 08:39:49.631 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
23697:M 20 Dec 08:39:49.632 * Increased maximum number of open files to 10032 (it was originally set to 4864).
23697:M 20 Dec 08:39:49.633 * Running mode=standalone, port=6379.
23697:M 20 Dec 08:39:49.633 # Server initialized
23697:M 20 Dec 08:39:49.633 * DB loaded from disk: 0.000 seconds
23697:M 20 Dec 08:39:49.633 * Ready to accept connections
-#if defined(__ATOMIC_RELAXED) && (!defined(__clang__) || __apple_build_version__ > 4210057)
+#if defined(__ATOMIC_RELAXED) && (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057)
/* Copyright (C) 2016 Salvatore Sanfilippo. All Rights Resereved.
* This code is released under the BSD 3 clause license. */
#include <math.h>
#include <stdlib.h>
/* Return a random number with normal distribution and the specified
* mean and variance. It uses the "polar method" but does not cache one
* of the previously generated random numbers, it just returns a single
* one per iteration in order for the function to be completely stateless. */
# Create a neural network with 2 inputs, 1 output, 3 hidden units.
127.0.0.1:6379> NR.CREATE net regressor 2 3 -> 1 normalize dataset 50 test 10
(integer) 13
# Feed it with some data.
127.0.0.1:6379> NR.OBSERVE net 1 2 -> 3
1) (integer) 1
2) (integer) 0
@antirez
antirez / nn.h
Last active September 23, 2016 22:30
#ifndef __NN_H
#define __NN_H
/* Data structures.
* Nets are not so 'dynamic', but enough to support
* an arbitrary number of layers, with arbitrary units for layer.
* Only fully connected feed-forward networks are supported. */
struct AnnLayer {
int units;
double *output; /* output[i], output of i-th unit */