177 Commits

Author SHA1 Message Date
zhaozhao.zz
22950a6284 LFU: do some changes about LFU to find hotkeys
Firstly, use access time to replace the decreas time of LFU.
For function LFUDecrAndReturn,
it should only try to get decremented counter,
not update LFU fields, we will update it in an explicit way.
And we will times halve the counter according to the times of
elapsed time than server.lfu_decay_time.
Everytime a key is accessed, we should update the LFU
including update access time, and increment the counter after
call function LFUDecrAndReturn.
If a key is overwritten, the LFU should be also updated.
Then we can use `OBJECT freq` command to get a key's frequence,
and LFUDecrAndReturn should be called in `OBJECT freq` command
in case of the key has not been accessed for a long time,
because we update the access time only when the key is read or
overwritten.
2017-11-27 18:39:22 +01:00
antirez
02aafda9af Improve OBJECT HELP descriptions.
See #4472.
2017-11-27 18:09:08 +01:00
Salvatore Sanfilippo
05c596e1a3 Merge pull request #4472 from itamarhaber/object_patch
A minor fix and `help` subcommand for `OBJECT`
2017-11-27 12:41:02 +01:00
Itamar Haber
fc5c3bdd1b Adds OBJECT help 2017-11-24 19:59:05 +02:00
Itamar Haber
b9329a2959 Prevents OBJECT freq with noeviction
When maxmemory is set to noeviction, idletime is implicitly kept. This renders access frequency nonsensical.
2017-11-24 19:58:37 +02:00
Oran Agra
43a17cc78d fix string to double conversion, stopped parsing on \0 even if the string has more data.
getLongLongFromObject calls string2ll which has this line:
/* Return if not all bytes were used. */
so if you pass an sds with 3 characters "1\01" it will fail.

but getLongDoubleFromObject calls strtold, and considers it ok if eptr[0]==`\0`
i.e. if the end of the string found by strtold ends with null terminator

127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> setrange a 2 2
(integer) 3
127.0.0.1:6379> get a
"1\x002"
127.0.0.1:6379> incrbyfloat a 2
"3"
127.0.0.1:6379> get a
"3"
2017-11-23 17:15:27 +02:00
Itamar Haber
fed5b3b1d0 Fixes an off-by-one in argument handling of MEMORY USAGE
Fixes #4430
2017-11-08 16:08:29 +02:00
antirez
a259494736 More robust object -> double conversion.
Certain checks were useless, at the same time certain malformed inputs
were accepted without problems (emtpy strings parsed as zero).
Cases where strtod() returns ERANGE but we still want to parse the input
where ok in getDoubleFromObject() but not in the long variant.

As a side effect of these fixes, this commit fixes #4391.
2017-10-30 13:39:58 +01:00
antirez
dcd0474384 Add MEMORY DOCTOR to MEMORY HELP. 2017-07-28 17:47:54 +02:00
Guy Benoish
5f71d50d1d Merge branch 'unstable' of https://github.com/antirez/redis into unstable 2017-03-02 13:25:05 +02:00
oranagra
66f03b8340 add SDS_NOINIT option to sdsnewlen to avoid unnecessary memsets.
this commit also contains small bugfix in rdbLoadLzfStringObject
a bug that currently has no implications.
2017-02-23 03:04:08 -08:00
Jan-Erik Rediger
4456ba2d87 Don't divide by zero
Previously Redis crashed on `MEMORY DOCTOR` when it has no slaves attached.

Fixes #3783
2017-01-27 16:24:14 +01:00
miter
44353407b7 Change switch statment to if statment 2017-01-26 21:36:26 +09:00
antirez
59e4ec8835 MEMORY USAGE: support for modules data types.
As a side effect of supporting it, we no longer crash when MEMORY USAGE
is called against a module data type.

Close #3637.
2017-01-12 09:47:57 +01:00
Guy Benoish
3ee8be85bf enlarged buffer given to ld2string 2017-01-11 19:24:19 +02:00
wangshaonan
99a3e17fae Add '\n' to MEMORY DOCTOR command output message when num_reports
is 0 or empty is 1
2016-12-06 03:11:27 +00:00
Guy Benoish
7145d161a0 Fixed wrong sizeof(client) in object.c 2016-10-31 15:08:17 +02:00
Dvir Volk
b8a375fe59 added RM_CreateStringPrintf 2016-09-21 12:30:38 +03:00
antirez
ed63dadc10 Typo fixed from MEMORY DOCTOR output. 2016-09-16 16:52:00 +02:00
antirez
44fedc3f7b Surround allocator name with quotes in MEMORY DOCTOR output. 2016-09-16 16:40:25 +02:00
antirez
6249fdc544 MEMORY DOCTOR initial implementation. 2016-09-16 16:36:53 +02:00
antirez
303d981cab Provide percentage of memory peak used info. 2016-09-16 10:43:19 +02:00
antirez
9dce1c8dcd Memory related subcommands of DEBUG moved to MEMORY. 2016-09-16 10:26:23 +02:00
antirez
2decf8957e Group MEMORY command related APIs together in the source code. 2016-09-16 10:12:04 +02:00
antirez
28dc0a22a7 objectComputeSize(): skiplist nodes have different sizes.
The size of the node depends on the node level, however it is not stored
into the node itself, is an implicit information, so we use
zmalloc_size() in order to compute the sorted set size.
2016-09-15 17:43:13 +02:00
antirez
340c5546a1 MEMORY command: HELP + dataset percentage (like in INFO). 2016-09-15 17:33:16 +02:00
antirez
3819a712ac MEMORY USAGE: SAMPLES option added + fixes to size computation.
The new SAMPLES option is added, defaulting to 5, and with 0 being a
special value to scan the whole set of elements.

Fixes to the object size computation were made since the original PR
assumed data structures still contaning robj structures, while now after
the lazyfree changes, are all SDS strings.
2016-09-15 15:25:14 +02:00
antirez
fa9588a275 C struct memoh renamed redisMemOverhead. API prototypes added. 2016-09-15 09:44:07 +02:00
antirez
a1045e9651 MEMORY OVERHEAD refactored into a generic API. 2016-09-15 09:37:55 +02:00
antirez
f705ad52db MEMORY OVERHEAD implemented (using Oran Agra initial implementation).
This code was extracted from @oranagra PR #3223 and modified in order
to provide only certain amounts of information compared to the original
code. It was also moved from DEBUG to the newly introduced MEMORY
command. Thanks to Oran for the implementation and the PR.

It implements detailed memory usage stats that can be useful in both
provisioning and troubleshooting memory usage in Redis.
2016-09-13 17:39:25 +02:00
antirez
cf49be57a5 objectComputeSize(): estimate collections sampling N elements.
For most tasks, we need the memory estimation to be O(1) by default.
This commit also implements an initial MEMORY command.
Note that objectComputeSize() takes the number of samples to check as
argument, so MEMORY should be able to get the sample size as option
to make precision VS CPU tradeoff tunable.

Related to: PR #3223.
2016-09-13 10:28:23 +02:00
oranagra
41899d26ef Adding objectComputeSize() function. 2016-09-12 16:36:59 +02:00
antirez
ef404d604b Fix maxmemory shared integer check bug introduced with LFU. 2016-07-21 11:14:18 +02:00
antirez
368aa4da99 LFU: Initial naive eviction cycle.
It is possible to get better results by using the pool like in the LRU
case. Also from tests during the morning I believe the current
implementation has issues in the frequency decay function that should
decrease the counter at periodic intervals.
2016-07-18 13:50:19 +02:00
antirez
1e7f752571 LFU: Redis object level implementation.
Implementation of LFU maxmemory policy for anything related to Redis
objects. Still no actual eviction implemented.
2016-07-15 12:12:58 +02:00
antirez
c50290ee69 Expire and LRU related code moved into different files. 2016-07-06 15:24:06 +02:00
antirez
6ad67c330f getLongLongFromObject: use string2ll() instead of strict_strtoll().
strict_strtoll() has a bug that reports the empty string as ok and
parses it as zero.

Apparently nobody ever replaced this old call with the faster/saner
string2ll() which is used otherwise in the rest of the Redis core.

This commit close #3333.
2016-07-06 11:43:33 +02:00
Salvatore Sanfilippo
cea51549b8 Merge pull request #3336 from yossigo/create_string_from_string
Add RedisModule_CreateStringFromString().
2016-06-23 16:16:28 +02:00
tielei
46312a6cae A string with 21 chars is not representable as a 64-bit integer. 2016-06-23 19:53:56 +08:00
Yossi Gottlieb
c7ec9f280f Add RedisModule_CreateStringFromString(). 2016-06-22 21:02:40 +03:00
Yossi Gottlieb
83a4257f72 Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
Salvatore Sanfilippo
5ce6c56f98 Merge pull request #3283 from ideal/unstable
fix mistake in comment in object.c
2016-06-15 15:53:19 +02:00
antirez
9deb98167b Modules: support for modules native data types. 2016-06-03 18:14:04 +02:00
ideal
641f8c1c2c fix mistake comment in object.c 2016-05-30 16:57:36 +08:00
antirez
5eb85d8fe7 Lazyfree: Hash converted to use plain SDS WIP 4. 2015-10-01 13:02:25 +02:00
antirez
5ae12b50d1 Lazyfree: Hash converted to use plain SDS WIP 2. 2015-10-01 13:02:24 +02:00
antirez
5fd01e29d9 Lazyfree: Hash converted to use plain SDS WIP 1. 2015-10-01 13:02:24 +02:00
antirez
062bf5ce19 Lazyfree: Convert Sets to use plains SDS (several commits squashed). 2015-10-01 13:02:24 +02:00
antirez
ca8d13bd90 Lazyfree: a first implementation of non blocking DEL. 2015-10-01 13:00:19 +02:00
antirez
c15cac0d77 RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00