147 Commits

Author SHA1 Message Date
antirez
fe49700cf5 Added a README into deps on dependencies and how to upgrade. 2015-10-06 10:56:16 +02:00
antirez
7b940930d0 deps/hiredis SDS updated to version 2.0.0. 2015-07-25 17:51:48 +02:00
antirez
0b469c7882 Jemalloc: use LG_QUANTUM of 3 for AMD64 and I386.
This gives us a 24 bytes size class which is dict.c dictEntry size, thus
improving the memory efficiency of Redis significantly.
Moreover other non 16 bytes aligned tiny classes are added that further
reduce the fragmentation of the allocator.

Technically speaking LG_QUANTUM should be 4 on i386 / AMD64 because of
SSE types and other 16 bytes types, however we don't use those, and our
jemalloc only targets Redis.

New versions of Jemalloc will have an explicit configure switch in order
to specify the quantum value for a platform without requiring any change
to the Jemalloc source code: we'll switch to this system when available.

This change was originally proposed by Oran Agra (@oranagra) as a change
to the Jemalloc script to generate the size classes define. We ended
doing it differently by changing LG_QUANTUM since it is apparently the
supported Jemalloc method to obtain a 24 bytes size class, moreover it
also provides us other potentially useful size classes.

Related to issue #2510.
2015-07-24 10:20:02 +02:00
antirez
df481b24f2 Geo: use ULL suffix for unsigned 64 bit constants. 2015-07-09 11:27:58 +02:00
antirez
ecb568558c Geo: -Ofast breaks builds on older GCCs. 2015-07-09 11:25:29 +02:00
antirez
ccce923ec6 Geo: validate long,lat passed by user via API 2015-07-06 18:39:25 +02:00
antirez
0935123deb Geo: sync faster decoding from krtm that synched from Ardb.
Instead of successive divisions in iteration the new code uses bitwise
magic to interleave / deinterleave two 32bit values into a 64bit one.
All tests still passing and is measurably faster, so worth it.
2015-07-01 16:12:08 +02:00
antirez
555e3c9470 Geo: added my copyright notice in modified files. 2015-06-29 16:34:02 +02:00
antirez
f7922b6db7 Geo: GEODIST and tests. 2015-06-29 12:44:34 +02:00
antirez
9049156d53 Geo: from lat,lon API to lon,lat API according to GIS standard
The GIS standard and all the major DBs implementing GIS related
functions take coordinates as x,y that is longitude,latitude.
It was a bad start for Redis to do things differently, so even if this
means that existing users of the Geo module will be required to change
their code, Redis now conforms to the standard.

Usually Redis is very backward compatible, but this is not an exception
to this rule, since this is the first Geo implementation entering the
official Redis source code. It is not wise to try to be backward
compatible with code forks... :-)

Close #2637.
2015-06-26 10:58:27 +02:00
antirez
d003b67b7f Geo: Fix geohashEstimateStepsByRadius() step underestimation.
The returned step was in some case not enough towards normal
coordinates (for example when our search position was was already near the
margin of the central area, and we had to match, using the east or west
neighbor, a very far point). Example:

    geoadd points 67.575457940146066 -62.001317572780565 far
    geoadd points 66.685439060295664 -58.925040587282297 center
    georadius points 66.685439060295664 -58.925040587282297 200 km

In the above case the code failed to find a match (happens at smaller
latitudes too) even if far and center are at less than 200km.

Another fix introduced by this commit is a progressively larger area
towards the poles, since meridians are a lot less far away, so we need
to compensate for this.

The current implementation works comparably to the Tcl brute-force
stress tester implemented in the fuzzy test in the geo.tcl unit for
latitudes between -70 and 70, and is pretty accurate over +/-80 too,
with sporadic false negatives.

A more mathematically clean implementation is possible by computing the
meridian distance at the specified latitude and computing the step
according to it.
2015-06-24 10:42:16 +02:00
antirez
7774b65494 Geo: big refactoring of geo.c, zset.[ch] removed.
This commit simplifies the implementation in a few ways:

1. zsetScore implementation improved a bit and moved into t_zset.c where
   is now also used to implement the ZSCORE command.

2. Range extraction from the sorted set remains a separated
   implementation from the one in t_zset.c, but was hyper-specialized in
   order to avoid accumulating results into a list and remove the ones
   outside the radius.

3. A new type is introduced: geoArray, which can accumulate geoPoint
   structures in a vector with power of two expansion policy. This is
   useful since we have to call qsort() against it before returning the
   result to the user.

4. As a result of 1, 2, 3, the two files zset.c and zset.h are now
   removed, including the function to merge two lists (now handled with
   functions that can add elements to existing geoArray arrays) and
   the machinery used in order to pass zset results.

5. geoPoint structure simplified because of the general code structure
   simplification, so we no longer need to take references to objects.

6. Not counting the JSON removal the refactoring removes 200 lines of
   code for the same functionalities, with a simpler to read
   implementation.

7. GEORADIUS is now 2.5 times faster testing with 10k elements and a
   radius resulting in 124 elements returned. However this is mostly a
   side effect of the refactoring and simplification. More speed gains
   can be achieved by trying to optimize the code.
2015-06-23 08:42:57 +02:00
antirez
471d4f914f Geo: removed useless functions, Marcatore coordinates, bool usage 2015-06-22 11:16:15 +02:00
Matt Stancliff
b9136b5aee [In-Progress] Add Geo Commands
Current todo:
  - replace functions in zset.{c,h} with a new unified Redis
    zset access API.

Once we get the zset interface fixed, we can squash
relevant commits in this branch and have one nice commit
to merge into unstable.

This commit adds:
  - Geo commands
  - Tests; runnable with: ./runtest --single unit/geo
  - Geo helpers in deps/geohash-int/
  - src/geo.{c,h} and src/geojson.{c,h} implementing geo commands
  - Updated build configurations to get everything working
  - TEMPORARY: src/zset.{c,h} implementing zset score and zset
    range reading without writing to client output buffers.
  - Modified linkage of one t_zset.c function for use in zset.c

Conflicts:
	src/Makefile
	src/redis.c
2015-06-22 09:07:13 +02:00
Ben Murphy
e881325094 disable loading lua bytecode 2015-06-03 13:33:28 +02:00
antirez
e0e33a2fa5 Scripting: Lua cmsgpack lib updated to include str8 support 2015-06-03 08:44:43 +02:00
antirez
aa6201e6ab Fix Sentinel memory leak (hiredis bug)
This fixes issue #2535, that was actually an hiredis library bug (I
submitted an issue and fix to the redis/hiredis repo as well).

When an asynchronous hiredis connection subscribes to a Pub/Sub channel
and gets an error, and in other related conditions, the function
redisProcessCallbacks() enters a code path where the link is
disconnected, however the function returns before freeing the allocated
reply object. This causes a memory leak. The memory leak was trivial to
trigger in Redis Sentinel, which uses hiredis, every time we tried to
subscribe to an instance that required a password, in case the Sentinel
was configured either with the wrong password or without password at
all. In this case, the -AUTH error caused the leaking code path to be
executed.

It was verified with Valgrind that after this change the leak no longer
happens in Sentinel with a misconfigured authentication password.
2015-04-28 22:10:23 +02:00
Matt Stancliff
cde821759e Set optional 'static' for Quicklist+Redis
This also defines REDIS_STATIC='' for building everything
inside src/ and everything inside deps/lua/.
2015-01-02 11:16:10 -05:00
antirez
68ee900138 Lua cmsgpack lib updated to latest version.
It fixes a bad bug that crashes the server in certain conditions
as shown in issue #2210.
2014-12-12 22:56:33 +01:00
antirez
5143a209e3 Simplify lua_cmsgpack macro and fix build on old Linux distros.
Thanks to @badboy for the help in checking the build after the fix.
2014-12-05 10:51:25 +01:00
Matt Stancliff
5fc1116614 Fix lua-cmsgpack 64 bit integer on 32 bit platform
This syncs lua-cmsgpack with the mattsta/lua-cmsgpack upstream.

Fixes #2161
2014-11-24 12:45:15 -05:00
antirez
de13a823dc lua_cjson.c Lua includes: angled -> quoted. 2014-11-14 17:16:23 +01:00
antirez
35591ab436 Merge remote-tracking branch 'origin/unstable' into unstable 2014-11-14 17:10:48 +01:00
Matt Stancliff
d29c753f92 Lua: upgrade cmsgpack to 0.4.0
Main reasons for upgrade:
  - Remove a warning when building Redis
  - Add multi pack/unpack
  - Improve memory usage and use Lua allocator properly
  - Fix some edge case encoding/decoding bugs
2014-11-14 17:08:51 +01:00
Matt Stancliff
d0564a032c Lua: remove new warning added by cjson header
clang doesn't like "extern inline" when no definition
is given right away.
2014-11-14 17:08:44 +01:00
Matt Stancliff
a7fbd433f3 Lua: Use Redis solaris compatability for cjson too
cjson calls isinf, but some Solaris versions don't have isinf
even with the attempted fix we have in deps/Makefile.

We can harmlessly include the Redis solarisfixes.h header to
give cjson proper isinf.

Note: cjson has a compile-time setting for using their own defined
isinf, but the Redis definition in solarisfixes.h is more complete.

Fixes antirez#1620
2014-11-14 17:08:39 +01:00
Matt Stancliff
586579851f Lua: Upgrade cjson to 2.1.0 (2012-03-01)
The new cjson has some improvements over our current version including
increased platform compatability, a new resource limit to restrict
decode depth, and better invalid number handling.

One minor change was required to deps/Makefile because this version
of cjson doesn't export itself globally, so we added a quick little
define of -DENABLE_CJSON_GLOBAL.

cjson now has an optional higher performing float parsing interface,
but we are not including it (g_fmt.c, dtoa.c) because it requires
endianness declaration during compile time.

This commit is exactly lua_cjson.c from 2.1.0 with one minor
change of altering the two Lua includes for local search
instead of system-wide importing.
2014-11-14 17:08:33 +01:00
Matt Stancliff
c3d2758a14 Lua: Add bitop
A few people have written custom C commands because bit
manipulation isn't exposed through Lua.  Let's give
them Mike Pall's bitop.

This adds bitop 1.0.2 (2012-05-08) from http://bitop.luajit.org/

bitop is imported as "bit" into the global namespace.

New Lua commands: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor,
bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap

Verification of working (the asserts would abort on error, so (nil) is correct):
127.0.0.1:6379> eval "assert(bit.tobit(1) == 1); assert(bit.band(1) == 1); assert(bit.bxor(1,2) == 3); assert(bit.bor(1,2,4,8,16,32,64,128) == 255)" 0
(nil)
127.0.0.1:6379> eval 'assert(0x7fffffff == 2147483647, "broken hex literals"); assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals"); assert(tostring(-1) == "-1", "broken tostring()"); assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()")' 0
(nil)

Tests also integrated into the scripting tests and can be run with:
./runtest --single unit/scripting

Tests are excerpted from `bittest.lua` included in the bitop distribution.
2014-10-09 11:51:30 -04:00
antirez
4b89fb5347 Linenoise README updated to match source code. 2014-10-06 09:49:44 +02:00
Aaron Rutkovsky
bd82bd65c0 Fix typos
Closes #1513
2014-09-29 06:49:07 -04:00
Matt Stancliff
04681171d5 Update linenoise accessory files
The core linenoise code was being backported, but not
the README or example.  It's less confusing for users
if everything matches across directories.

Fix inspired by @thrig

Closes #1872
2014-09-29 06:49:05 -04:00
antirez
73fc79234e Linenoise lib updated. 2014-09-22 14:55:54 +02:00
Matt Stancliff
53b0da3522 Fix hiredis getaddrinfo leak
Fixed in Redis by 6c2649b, but since that part of code
is largely copy/paste from Redis, the fix needs to be
ported over too.

Closes #2012
2014-09-18 14:47:55 -04:00
antirez
bb666fe7a4 Missing va_end also added in hiredis copy of sds.c. 2014-08-26 10:05:32 +02:00
Mariano Pérez Rodríguez
8794500289 Missing assert removal from sdsIncrLen()
Companion for 5e780be2ad0a86c98c5b9b4450f5e897923647db, but dealing with hiredis.
2014-08-25 15:24:15 -03:00
antirez
02b06ba8f0 Use unsigned integers in SDS header.
This raises the max string to 4GB without any downside.
2014-08-13 10:53:51 +02:00
Daniel Price
d4ad95a375 Define AR to help with lua cross-compilation
Closes #997
2014-08-12 11:26:34 +02:00
siahl
bb1347da8f Add support for compiling on AIX
Closes #1900
2014-08-07 12:12:54 +02:00
antirez
82d95f85f8 Silence different signs comparison warning in sds.c. 2014-06-23 11:50:24 +02:00
antirez
c52fcbddc8 Use Redis updated sds.c for deps/hiredis. 2014-06-23 11:44:50 +02:00
antirez
70ac5969a9 Dummy zmalloc.h restored into deps/hiredis. 2014-06-23 11:44:34 +02:00
Matt Stancliff
c3aad2aeee hiredis: Update to latest version
This is hiredis f225c276be7fd0646019b51023e3f41566633dfe

This update includes all changes that diverged inside of Redis since
the last update.  This version also allows optional source address
binding for connections which we need for some Sentinel deployments.
2014-06-23 11:44:34 +02:00
antirez
72090a63a7 Jemalloc updated to 3.6.0.
Not a single bug in about 3 months, and our previous version was
too old (3.2.0).
2014-06-20 14:59:20 +02:00
antirez
ddcc73bf56 Jemalloc update script added. 2014-06-20 14:53:57 +02:00
antirez
8954da8136 Linenoise updated, multiline mode enabled in redis-cli. 2014-03-13 15:11:08 +01:00
yihuang
a8ec7abb1b fix lua_cmsgpack pack map as array 2013-08-27 15:19:25 +02:00
antirez
09662d780e Fix sdsempty() prototype in sds.h. 2013-08-12 11:38:21 +02:00
antirez
b55bcdd3ab Use latest sds.c in the hiredis library under deps. 2013-07-25 10:32:19 +02:00
antirez
c3c836d3f9 hiredis: minimal IPv6 support. 2013-07-11 13:11:27 +02:00
antirez
a8d44cfdc6 Lua updated to version 5.1.5. 2013-04-29 12:00:54 +02:00