-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Adds memory information about the scripts' cache to INFO #4883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds memory information about the scripts' cache to INFO #4883
Conversation
Implementation notes: as INFO is "already broken", I didn't want to break it further. Instead of computing the server.lua_script dict size on every call, I'm keeping a running sum of the body's length and dict overheads.
This implementation is naive as it **does not** take into consideration dict rehashing, but that inaccuracy pays off in speed ;)
Demo time:
```bash
$ redis-cli info memory | grep "script"
used_memory_scripts:96
used_memory_scripts_human:96B
number_of_cached_scripts:0
$ redis-cli eval "" 0 ; redis-cli info memory | grep "script"
(nil)
used_memory_scripts:120
used_memory_scripts_human:120B
number_of_cached_scripts:1
$ redis-cli script flush ; redis-cli info memory | grep "script"
OK
used_memory_scripts:96
used_memory_scripts_human:96B
number_of_cached_scripts:0
$ redis-cli eval "return('Hello, Script Cache :)')" 0 ; redis-cli info memory | grep "script"
"Hello, Script Cache :)"
used_memory_scripts:152
used_memory_scripts_human:152B
number_of_cached_scripts:1
$ redis-cli eval "return redis.sha1hex(\"return('Hello, Script Cache :)')\")" 0 ; redis-cli info memory | grep "script"
"1be72729d43da5114929c1260a749073732dc822"
used_memory_scripts:232
used_memory_scripts_human:232B
number_of_cached_scripts:2
✔ 19:03:54 redis [lua_scripts-in-info-memory L ✚…⚑] $ redis-cli evalsha 1be72729d43da5114929c1260a749073732dc822 0
"Hello, Script Cache :)"
```
|
TODO: once merged, this needs to be added to INFO's documentation |
|
@itamarhaber, very good and needed improvement. Other than that, i think the scripts memory metric should include the following:
i think you should sum your server.lua_scripts_mem and the bullets i just suggested in |
|
@oranagra thanks for the review!
Note: someone needs to fix "MEMORY HELP" to follow the "standard" help mechanism. |
|
@itamarhaber, @oranagra Thanks, looks good but I'm going to change 42 ;-) |
|
Merged, thank you. |
As per https://github.com/antirez/redis/pull/4883 Signed-off-by: Itamar Haber <itamar@redislabs.com>
As per https://github.com/antirez/redis/pull/4883 Signed-off-by: Itamar Haber <itamar@redislabs.com>
|
Yippie :)
|
…mory Adds memory information about the scripts' cache to INFO
As per https://github.com/antirez/redis/pull/4883 Signed-off-by: Itamar Haber <itamar@redislabs.com>
Implementation notes: as INFO is "already broken", I didn't want to break it further. Instead of computing the server.lua_script dict size on every call, I'm keeping a running sum of the body's length and dict overheads.
This implementation is naive as it does not take into consideration dict rehashing, but that inaccuracy pays off in speed ;)
Demo time: