189 Commits

Author SHA1 Message Date
antirez
a889c94447 incrRefCount(): abort on statically allocated object. 2020-04-15 16:03:16 +02:00
antirez
fdd6da647d Speedup INFO by counting client memory incrementally.
Related to #5145.

Design note: clients may change type when they turn into replicas or are
moved into the Pub/Sub category and so forth. Moreover the recomputation
of the bytes used is problematic for obvious reasons: it changes
continuously, so as a conservative way to avoid accumulating errors,
each client remembers the contribution it gave to the sum, and removes
it when it is freed or before updating it with the new memory usage.
2020-04-07 16:53:13 +02:00
hayashier
253fcf98f8 fix typo from fss to rss 2020-02-27 18:00:47 +01:00
Guy Benoish
084dc68128 Some refactroing using getClientType instead of CLIENT_SLAVE 2020-02-12 14:15:56 +01:00
Guy Benoish
2ad427f862 ld2string should fail if string contains \0 in the middle
This bug affected RM_StringToLongDouble and HINCRBYFLOAT.
I added tests for both cases.

Main changes:
1. Fixed string2ld to fail if string contains \0 in the middle
2. Use string2ld in getLongDoubleFromObject - No point of
   having duplicated code here

The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble
because the long double string was saved with length+1 (An innocent
mistake, but it's actually a bug - The length passed to
RM_SaveLongDouble should not include the last \0).
2020-02-04 10:23:48 +01:00
Salvatore Sanfilippo
22c68cc3bf Merge branch 'unstable' into rm_get_server_info 2019-11-21 10:06:15 +01:00
Oran Agra
86e1f73bd6 rename RN_SetLRUOrLFU -> RM_SetLRU and RN_SetLFU
- the API name was odd, separated to two apis one for LRU and one for LFU
- the LRU idle time was in 1 second resolution, which might be ok for RDB
  and RESTORE, but i think modules may need higher resolution
- adding tests for LFU and for handling maxmemory policy mismatch
2019-11-10 09:27:01 +02:00
Salvatore Sanfilippo
ab520ef80f Merge pull request #6531 from oranagra/rm_save_long_double
Module API for loading and saving long double
2019-11-04 17:33:35 +01:00
Oran Agra
04df0cc328 Module API for loading and saving long double
looks like each platform implements long double differently (different bit count)
so we can't save them as binary, and we also want to avoid creating a new RDB
format version, so we save these are hex strings using "%La".

This commit includes a change in the arguments of ld2string to support this.
as well as tests for coverage and short reads.

coded by @guybe7
2019-11-03 16:42:31 +02:00
Oran Agra
2bbd305a33 Add module api for looking into INFO fields
- Add RM_GetServerInfo and friends
- Add auto memory for new opaque struct
- Add tests for new APIs

other minor fixes:
- add const in various char pointers
- requested_section in modulesCollectInfo was actually not sds but char*
- extract new string2d out of getDoubleFromObject for code reuse

Add module API for
2019-11-03 15:02:25 +02:00
Oran Agra
57649ce051 Module API for controlling LRU and LFU, and OpenKey without TOUCH
Some commands would want to open a key without touching it's LRU/LFU
similarly to the OBJECT or DEBUG command do.

Other commands may want to implement logic similar to what RESTORE
does (and in the future MIGRATE) and get/set the LRU or LFU.
2019-10-29 15:03:05 +02:00
Oran Agra
f484baa3ea trim the double implementation of jemalloc purge 2019-10-04 14:22:13 +03:00
Evgeny
4429a40317 Fix compilation error 2019-09-20 01:11:20 -07:00
antirez
b98016ca05 RESP3: Use verbatim in MEMORY subcommands. 2019-09-18 18:48:14 +02:00
antirez
203a7762dc Make EMBSTR case of #6261 more obvious. 2019-07-31 12:03:10 +02:00
Salvatore Sanfilippo
3dad067b17 Merge pull request #6261 from chendq8/robj
make memory usage consistent of robj with OBJ_ENCODING_INT
2019-07-31 11:54:11 +02:00
chendianqiang
4b89b52355 make memory usage consistent of robj with OBJ_ENCODING_INT 2019-07-22 17:45:30 +08:00
Oran Agra
527c297efb missing per-skiplist overheads in MEMORY USAGE
these had severe impact for small zsets, for instance ones with just one
element that is longer than 64 (causing it not to be ziplist encoded)
2019-07-04 15:20:49 +03:00
antirez
e8568bb341 Fix objectSetLRUOrLFU() when LFU underflows. 2019-03-14 17:06:59 +01:00
antirez
9c504573f1 Improve comments after merging #5834. 2019-03-14 12:47:36 +01:00
Guy Benoish
9cd3b12cdf Trim SDS free space of retained module strings
In some cases processMultibulkBuffer uses sdsMakeRoomFor to
expand the querybuf, but later in some cases it uses that query
buffer as is for an argv element (see "Optimization"), which means
that the sds in argv may have a lot of wasted space, and then in case
modules keep that argv RedisString inside their data structure, this
space waste will remain for long (until restarted from rdb).
2019-02-12 14:21:21 +01:00
antirez
c8304b099d RESP3: most null replies converted. 2019-01-09 17:00:29 +01:00
antirez
711abc03f1 RESP3: Use new deferred len API in object.c. 2019-01-09 17:00:29 +01:00
zhaozhao.zz
1e8605400b MEMORY command: make USAGE more accurate
In MEMORY USAGE command, we count the key argv[2] into usage,
but the argument in command may contains free spaces because of
sdsMakeRoomFor. But the key in db never contains free spaces
because we use sdsdup when dbAdd, so using the real key to
count the usage is more accurate.
2018-11-29 01:01:51 +08:00
antirez
3fd976a78c MEMORY command: make strcasecmp() conditional like the following. 2018-11-06 18:15:51 +01:00
Salvatore Sanfilippo
5dd561b484 Merge pull request #4526 from itamarhaber/memory_help
Standardizes `MEMORY HELP` subcommand
2018-11-06 18:13:17 +01:00
Salvatore Sanfilippo
f588805a52 Merge pull request #5453 from damz/pr/aof-buffer-evict
Overhead is the allocated size of the AOF buffer, not its length
2018-10-24 12:28:28 +02:00
Damien Tournoud
8b3154a0ea Overhead is the allocated size of the AOF buffer, not its length 2018-10-16 11:47:42 -07:00
hujiecs
57e64d5e62 several typos fixed, optimize MSETNX to avoid unnecessary loop 2018-10-16 15:48:03 +08:00
Salvatore Sanfilippo
159531c1c9 Merge pull request #5242 from oranagra/script_mem
script cache memory in INFO and MEMORY includes both script code and overheads
2018-10-02 16:03:05 +02:00
antirez
e670825ef9 Slave removal: remove slave from object.c. 2018-09-11 15:32:28 +02:00
Oran Agra
cdda01edef script cache memory in INFO and MEMORY includes both script code and overheads 2018-08-13 17:36:54 +03:00
antirez
d1e07d021e Change 42 to 1000 as warning level for cached scripts.
Related to #4883.
2018-07-23 18:44:58 +02:00
Salvatore Sanfilippo
63171b81b0 Merge pull request #4883 from itamarhaber/lua_scripts-in-info-memory
Adds memory information about the scripts' cache to INFO
2018-07-23 18:43:05 +02:00
Itamar Haber
a3c4ec8a84 Adds Lua overheads to MEMORY STATS, smartens the MEMORY DOCTOR 2018-07-22 21:16:00 +03:00
antirez
938d879c2a addReplySubSyntaxError() renamed to addReplySubcommandSyntaxError(). 2018-07-02 18:49:34 +02:00
Salvatore Sanfilippo
c44be0ab9b Merge pull request #4998 from itamarhaber/module_command_help
Module command help
2018-07-02 18:46:56 +02:00
Salvatore Sanfilippo
782db3117e Merge pull request #5051 from oranagra/streams_mem_estimate
fix streams memory estimation, missing raxSeek
2018-06-21 17:36:28 +02:00
Oran Agra
74c1fbbb9b fix streams memory estimation, missing raxSeek 2018-06-21 17:58:29 +03:00
Guy Benoish
4330bc3e3a Enhance RESTORE with RDBv9 new features
RESTORE now supports:
1. Setting LRU/LFU
2. Absolute-time TTL

Other related changes:
1. RDB loading will not override LRU bits when RDB file
   does not contain the LRU opcode.
2. RDB loading will not set LRU/LFU bits if the server's
   maxmemory-policy does not match.
2018-06-20 15:11:08 +07:00
antirez
1c783a2051 Refactor createObjectFromLongLong() to be suitable for value objects. 2018-06-18 16:55:16 +02:00
Itamar Haber
8f2e77dd23 Globally applies addReplySubSyntaxError 2018-06-07 18:39:36 +03:00
Salvatore Sanfilippo
bd1cba552f Merge pull request #4953 from soloestoy/fix-memory-overhead
MEMORY: fix the missing of monitor clients buffers
2018-05-31 17:31:24 +02:00
antirez
eb71d70571 Capitalize OBJECT HELP subcommands. 2018-05-31 17:11:46 +02:00
zhaozhao.zz
562a2931e7 MEMORY: fix the missing of monitor clients buffers 2018-05-27 16:34:58 +08:00
Salvatore Sanfilippo
2ceff42a53 Merge pull request #4703 from gechunlin/unstable
Update object.c
2018-03-22 16:32:45 +01:00
Salvatore Sanfilippo
d799fdf733 Merge pull request #4691 from oranagra/active_defrag_v2
Active defrag v2
2018-03-22 09:16:32 +01:00
antirez
18b62c3abd Streams: improve MEMORY USAGE computation, include CGs. 2018-03-20 17:50:40 +01:00
Oran Agra
5805907825 Adding real allocator fragmentation to INFO and MEMORY command + active defrag test
other fixes / improvements:
- LUA script memory isn't taken from zmalloc (taken from libc malloc)
  so it can cause high fragmentation ratio to be displayed (which is false)
- there was a problem with "fragmentation" info being calculated from
  RSS and used_memory sampled at different times (now sampling them together)

other details:
- adding a few more allocator info fields to INFO and MEMORY commands
- improve defrag test to measure defrag latency of big keys
- increasing the accuracy of the defrag test (by looking at real grag info)
  this way we can use an even lower threshold and still avoid false positives
- keep the old (total) "fragmentation" field unchanged, but add new ones for spcific things
- add these the MEMORY DOCTOR command
- deduct LUA memory from the rss in case of non jemalloc allocator (one for which we don't "allocator active/used")
- reduce sampling rate of the rss and allocator info
2018-03-12 15:08:52 +02:00
Salvatore Sanfilippo
601420cb73 Merge pull request #3828 from oranagra/sdsnewlen_pr
add SDS_NOINIT option to sdsnewlen to avoid unnecessary memsets.
2018-02-27 04:04:32 -08:00