Giter VIP home page Giter VIP logo

redis-tdigest's Introduction

redis-tdigest

Build Status

This is a Redis module for the t-digest data structure which can be used for accurate online accumulation of rank-based statistics such as quantiles and cumulative distribution at a point. The implementation is based on the Merging Digest implementation by the author.

Building & Loading

Before going ahead, make sure that the Redis server you're using has support for Redis modules.

First, you'll have to build the Redis t-digest module from source.

make

This should generate a shared library called tdigest.so in the root folder. You can now load it into Redis by using the following redis.conf configuration directive:

loadmodule /path/to/tdigest.so

Alternatively, you can load it on an already running Redis server by issuing the following commands:

MODULE LOAD /path/to/tdigest.so

API

TDIGEST.NEW key [compression]

Initializes a key to an empty t-digest structure with the compression provided or with the default compression of 400.

Reply: "OK"

TDIGEST.ADD key value count [value count ...]

Adds a value with the specified count. If key is missing, an empty t-digest structure is initialized with a default compression of 400. Returns the sum of counts for all values added.

Reply: long long

TDIGEST.MERGE destkey sourcekey [sourcekey ...]

Merges one or more sourcekey into destkey. If destkey is missing, an empty t-digest structure is initialized with a default compression of 400.

Reply: "OK"

TDIGEST.CDF key value [value ...]

Returns the cumulative distribution for all provided values. value must be a double. The cumulative distribution returned for all values is between 0..1.

Reply: double array or nil if key missing

TDIGEST.QUANTILE key quantile [quantile ...]

Returns the estimate values at all provided quantiles. quantile must be a double between 0..1.

Reply: double array or nil if key missing

TDIGEST.DEBUG key

Prints debug information about the t-digest.

Reply: bulk strings array

The reply is of the form:

1) TDIGEST (<compression>, <num_centroids>, <memory size>)
2)   CENTROID (<mean>, <weight>)
3)   CENTROID (<mean>, <weight>)
4)   CENTROID (<mean>, <weight>)
5)   ...

Centroids are printed in sorted order with respect to their mean.

Testing

The integration tests require a running Redis server so you must have redis-server on your PATH or pass its location in an environment variable called REDIS_SERVER. Tests are written in Python and use the pytest unit testing library.

make test

Contributing

Bug reports, feature and pull requests are welcome! Please add tests for any non-trivial changes you submit.

redis-tdigest's People

Contributors

bpo avatar itamarhaber avatar usmanm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis-tdigest's Issues

the module got coredump

Our redis instance running with tdigest module got coredump in every 4-5 days.
gdb provides backtrace as below.
Could you please take a look at it?
Tks.

(gdb) bt
#0 0x00007f015ab41495 in raise () from /lib64/libc.so.6
#1 0x00007f015ab42c75 in abort () from /lib64/libc.so.6
#2 0x00007f015ab7f3a7 in __libc_message () from /lib64/libc.so.6
#3 0x00007f015ab84dee in malloc_printerr () from /lib64/libc.so.6
#4 0x00007f015ab87c80 in _int_free () from /lib64/libc.so.6
#5 0x00007f0151ffa3f5 in tdigestCompress (t=0x7f0130086750) at src/tdigest.c:176
#6 0x00007f0151ff953c in TDigestTypeAdd_RedisCommand (ctx=0x7ffccde4c350, argv=, argc=) at src/command.c:110
#7 0x0000000000490c90 in RedisModuleCommandDispatcher (c=0x7f0150a2be40) at module.c:466
#8 0x0000000000429337 in call (c=0x7f0150a2be40, flags=15) at server.c:2224
#9 0x00000000004299a5 in processCommand (c=0x7f0150a2be40) at server.c:2505
#10 0x0000000000439b2d in processInputBuffer (c=0x7f0150a2be40) at networking.c:1330
#11 0x0000000000424aed in aeProcessEvents (eventLoop=0x7f015463b0a0, flags=11) at ae.c:421
#12 0x0000000000424e0b in aeMain (eventLoop=0x7f015463b0a0) at ae.c:464
#13 0x000000000042da22 in main (argc=, argv=0x7ffccde4c648) at server.c:3885

(gdb) bt full
#0 0x00007f015ab41495 in raise () from /lib64/libc.so.6
No symbol table info available.
#1 0x00007f015ab42c75 in abort () from /lib64/libc.so.6
No symbol table info available.
#2 0x00007f015ab7f3a7 in __libc_message () from /lib64/libc.so.6
No symbol table info available.
#3 0x00007f015ab84dee in malloc_printerr () from /lib64/libc.so.6
No symbol table info available.
#4 0x00007f015ab87c80 in _int_free () from /lib64/libc.so.6
No symbol table info available.
#5 0x00007f0151ffa3f5 in tdigestCompress (t=0x7f0130086750) at src/tdigest.c:176
unmerged_centroids = 0x1f20a30
unmerged_weight =
num_unmerged =
old_num_centroids = 630
i =
j = 630
args = {t = 0x7f0130086750, centroids = 0x1f21200, idx = 630, weight_so_far = 393204, k1 = 399.2966162507218, min = 0.14999999999999999, max = 511.43741628850984}
#6 0x00007f0151ff953c in TDigestTypeAdd_RedisCommand (ctx=0x7ffccde4c350, argv=, argc=) at src/command.c:110
key = 0x7f0154623000
type = 6
num_added = 1
values = 0x7f0130bc6810
counts = 0x7f0130bc6818
i =
t = 0x7f0130086750
total_count =
#7 0x0000000000490c90 in RedisModuleCommandDispatcher (c=0x7f0150a2be40) at module.c:466
cp =
ctx = {getapifuncptr = 0x491320, module = 0x7f015461b0c0, client = 0x7f0150a2be40, blocked_client = 0x0, amqueue = 0x7f013e59c300, amqueue_len = 16, amqueue_used = 1, flags = 2,
postponed_arrays = 0x0, postponed_arrays_count = 0, blocked_privdata = 0x0, keys_pos = 0x0, keys_count = 0, pa_head = 0x7f0130bc6800}
#8 0x0000000000429337 in call (c=0x7f0150a2be40, flags=15) at server.c:2224
dirty = 23916351
start = 1517577099955319
duration =
client_old_flags = 0
prev_also_propagate = {ops = 0x0, numops = 0}
#9 0x00000000004299a5 in processCommand (c=0x7f0150a2be40) at server.c:2505
No locals.
#10 0x0000000000439b2d in processInputBuffer (c=0x7f0150a2be40) at networking.c:1330
No locals.
#11 0x0000000000424aed in aeProcessEvents (eventLoop=0x7f015463b0a0, flags=11) at ae.c:421
fe = 0x7f01542024a0
mask = 1
fd = 293
rfired = 1
j =
shortest =
tvp =
processed =
numevents = 1
#12 0x0000000000424e0b in aeMain (eventLoop=0x7f015463b0a0) at ae.c:464
No locals.
#13 0x000000000042da22 in main (argc=, argv=0x7ffccde4c648) at server.c:3885
tv = {tv_sec = 1517061481, tv_usec = 930087}
j =
hashseed = "1a86649ef203608a"
background =

Please provide a release (or tags).

It is hard to build images with this package because there are no releases or git tags. Can we have such?

(I'd of course be happy to send PRs to do this -- just making sure you agree, checking if you have a preference for releasing or "just" tagging, and whether you have preference for an initial version number!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.