mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 04:48:20 +08:00
mdbx: move madvise(MADV_RANDOM) to under control of MDBX_NORDAHEAD flag.
Change-Id: Ied2473ad054797a20ec2c177106a9a7e85fab1d1
This commit is contained in:
parent
e04ea50c18
commit
c51a6e6d95
@ -6568,17 +6568,16 @@ static int __cold mdbx_env_map(MDBX_env *env, const int is_exclusive,
|
||||
return errno;
|
||||
#endif
|
||||
|
||||
#if defined(MADV_RANDOM)
|
||||
if (unlikely(madvise(env->me_map, env->me_mapsize, MADV_RANDOM) != 0))
|
||||
return errno;
|
||||
#elif defined(POSIX_MADV_RANDOM)
|
||||
rc = posix_madvise(env->me_map, env->me_mapsize, POSIX_MADV_RANDOM);
|
||||
if (unlikely(rc != 0))
|
||||
return errno;
|
||||
#endif
|
||||
|
||||
/* Turn on/off readahead. It's harmful when the DB is larger than RAM. */
|
||||
if (env->me_flags & MDBX_NORDAHEAD) {
|
||||
#if defined(MADV_RANDOM)
|
||||
if (unlikely(madvise(env->me_map, env->me_mapsize, MADV_RANDOM) != 0))
|
||||
return errno;
|
||||
#elif defined(POSIX_MADV_RANDOM)
|
||||
rc = posix_madvise(env->me_map, env->me_mapsize, POSIX_MADV_RANDOM);
|
||||
if (unlikely(rc != 0))
|
||||
return errno;
|
||||
#endif
|
||||
#ifdef POSIX_FADV_DONTNEED
|
||||
rc = posix_fadvise(env->me_fd, 0, env->me_mapsize, POSIX_FADV_DONTNEED);
|
||||
if (unlikely(rc != 0))
|
||||
|
Loading…
x
Reference in New Issue
Block a user