Skip to content

Commit

Permalink
Free strings objects instead of dismissing
Browse files Browse the repository at this point in the history
Instead of dismissing with madvise(MADV_DONTNEED) we free it via the
allocator. This has advantage that it allows the allocator to
accumulate free buffers to free whole pages. While madvise is nop
if the buffer is less than a page. The allocator overhead is
minimal, because raw strings (sds) use the fast path.

Signed-off-by: Vadym Khoptynets <vadymkh@amazon.com>
  • Loading branch information
poiuj committed Aug 12, 2024
1 parent 14a835d commit e2c17ac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,14 @@ void dismissSds(sds s) {
dismissMemory(sdsAllocPtr(s), sdsAllocSize(s));
}

/* See dismissObject() */
/* See dismissObject(). String object is an exception. Instead of
* dismissing it with madvise(MADV_DONTNEED) we free it via the
* allocator. This has advantage that it allows the allocator to
* accumulate free buffers to free whole pages. While madvise is nop
* if the buffer is less than a page. The allocator overhead is
* minimal, because raw strings (sds) use the fast path. */
void dismissStringObject(robj *o) {
if (o->encoding == OBJ_ENCODING_RAW) {
dismissSds(o->ptr);
}
freeStringObject(o);
}

/* See dismissObject() */
Expand Down

0 comments on commit e2c17ac

Please sign in to comment.