Skip to content

Instantly share code, notes, and snippets.

Set 1 HLL 1 Set 2 HLL 2 S1 ∪ S2 HLL1 ∪ HLL2 S1 ∩ S2 HLL1 ∩ HLL2
6987812 6997888 6962294 6951998 8550732 8553641 5399374 (63.000000%) 5398755 (63.116455%)
7141370 7158982 3678358 3684955 8546742 8547740 2272986 (26.000000%) 2314317 (27.075192%)
3124534 3107282 8651079 8604982 10227258 10230622 1548355 (15.000000%) 1506744 (14.727785%)
8850249 8862284 5290225 5308950 9375807 9387095 4764667 (50.000000%) 4781208 (50.933841%)
667001 665795 2030138 2019862 2217972 2209121 479167 (21.000000%) 469897 (21.270768%)
1344715 1355003 5560979 5585400 6788416 6799020 117278 (1.000000%) 122419 (1.800539%)
9527013 9539805 8888494 8904840 13514502 13547342 4901005 (36.000000%) 4923976 (36.346436%)
1336356 1347820 183299 183805 1432428 1439300 87227 (6.000000%) 88551 (6.152

Meltdown fix impact on Redis performances in virtualized environments

UPDATE: apparently kernel difference may have a serious impact, so I'll redo the test from scratch.

Test performed with AOF enabled, fsync policy 1 second, allowing the rewrites to be triggered.

Command lines used:

@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@dvirsky
dvirsky / redis-bashcomplete
Last active July 20, 2017 00:47
Bash completion for redis server and cli
# bash completion for redis-cli and redis-server
have redis-server &&
_redisserver()
{
local cur prev split=false
COMPREPLY=()
_get_comp_words_by_ref cur prev

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
@itamarhaber
itamarhaber / redis-watch-trivia-archive.md
Last active December 3, 2015 15:18
Redis Watch Trivia "Facts" - a Meta Archive

Redis Watch Trivia "Facts"

a Meta Archive

Look for a new #RedisTrivia fact every Thursday with your Redis Watch newsletter :)

Lifted with permission from the Redis Watch Archive: https://redislabs.com/redis-watch-archive

  1. Redis stands for REmote DIctionary Server
  2. everybody knows that Redis' default port is 6379, but have you ever wondered why? The answer is that 6379 spells MERZ on the phone's keypad (want to know what MERZ is? Read the appendix at http://oldblog.antirez.com/post/redis-as-LRU-cache.html [warning: slightly NSFW links inside])
@alexanderscott
alexanderscott / COPY.lua
Last active March 22, 2019 21:28
Redis Lua script to copy a key without knowing its type
-- @desc: Copy a key without knowing its type
-- @usage: redis-cli EVAL "$(cat COPY.lua)" 2 <key> <destKey>
local function COPY(key, dest)
local keyType = redis.call("TYPE", key)
if keyType == "set" then redis.call("SUNIONSTORE", dest, key)
elseif keyType == "zset" then redis.call("ZUNIONSTORE", dest, 1, key)
elseif keyType == "list" then redis.call("SORT", key, "BY", "NOSORT", "STORE", dest)
elseif keyType == "string" then redis.call("SET", dest, redis.call("GET", key))
@antirez
antirez / xmas.c
Created December 24, 2014 18:48
Happy xmas!
#include <stdio.h>
#include <stdlib.h>
int
main()
{int h=9,
d=0,x;while
(h--){for(x=0;
x<39;x++){int a=x
-6;if(a<0)a=-a;printf
@tylerneylon
tylerneylon / learn.lua
Last active April 2, 2024 15:09
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@jboner
jboner / latency.txt
Last active April 25, 2024 11:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD