Reclaim page cache memory used by the AOF file after loading (#13811)

We can reclaim page cache memory used by the AOF file after loading,
since we don't read AOF again, corresponding to
https://github.com/redis/redis/pull/11248

There is a test after loading 9.5GB AOF, this PR uses much less
`buff/cache` than unstable.

**Unstable**
```
$ free -m
               total        used        free      shared  buff/cache   available
Mem:           31293       16181        4562          13       10958       15111
Swap:              0           0           0
```
**This PR**
```
$ free -m
               total        used        free      shared  buff/cache   available
Mem:           31293       15391       15854          13         439       15902
Swap:              0           0           0
```

---------

Co-authored-by: debing.sun <debing.sun@redis.com>
This commit is contained in:
Yuan Wang 2025-05-09 10:05:37 +08:00 committed by GitHub
parent 714ea20fec
commit 191afb8903
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -1725,7 +1725,10 @@ cleanup:
if (fakeClient) freeClient(fakeClient);
server.current_client = old_cur_client;
server.executing_client = old_exec_client;
int fd = dup(fileno(fp));
fclose(fp);
/* Reclaim page cache memory used by the AOF file in background. */
if (fd >= 0) bioCreateCloseJob(fd, 0, 1);
sdsfree(aof_filepath);
return ret;
}