summaryrefslogtreecommitdiff
path: root/src/zmalloc.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-03-24 12:00:20 +0100
committerantirez <antirez@gmail.com>2014-03-24 12:00:20 +0100
commit93253c27620647deb3cb60e2666fbf7db9eff4cb (patch)
treee502e4e0707bc148c289f1b18723e74be72d170c /src/zmalloc.c
parent30639c8ca957b3ece9985d8261f89b4494494886 (diff)
downloadredis-93253c27620647deb3cb60e2666fbf7db9eff4cb.tar.gz
Sample and cache RSS in serverCron().
Obtaining the RSS (Resident Set Size) info is slow in Linux and OSX. This slowed down the generation of the INFO 'memory' section. Since the RSS does not require to be a real-time measurement, we now sample it with server.hz frequency (10 times per second by default) and use this value both to show the INFO rss field and to compute the fragmentation ratio. Practically this does not make any difference for memory profiling of Redis but speeds up the INFO call significantly.
Diffstat (limited to 'src/zmalloc.c')
-rw-r--r--src/zmalloc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/zmalloc.c b/src/zmalloc.c
index e7e97aa67..d0cf726cb 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -321,8 +321,8 @@ size_t zmalloc_get_rss(void) {
#endif
/* Fragmentation = RSS / allocated-bytes */
-float zmalloc_get_fragmentation_ratio(void) {
- return (float)zmalloc_get_rss()/zmalloc_used_memory();
+float zmalloc_get_fragmentation_ratio(size_t rss) {
+ return (float)rss/zmalloc_used_memory();
}
#if defined(HAVE_PROC_SMAPS)