Commit e63d76be authored by Michael Tremer's avatar Michael Tremer

database: Call madvise() to tell the kernel that we will randomly access the data

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 975f280f
......@@ -243,6 +243,9 @@ ERROR:
Maps the entire database into memory
*/
static int loc_database_mmap(struct loc_database* db) {
int r;
// Get file descriptor
int fd = fileno(db->f);
// Determine the length of the database
......@@ -264,6 +267,13 @@ static int loc_database_mmap(struct loc_database* db) {
DEBUG(db->ctx, "Mapped database of %zu byte(s) at %p\n", db->length, db->data);
// Tell the system that we expect to read data randomly
r = madvise(db->data, db->length, MADV_RANDOM);
if (r) {
ERROR(db->ctx, "madvise() failed: %m\n");
return r;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment