Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use madvise(MADV_RANDOM) when torrenting mmaped files to reduce disk readahead #7409

Open
wants to merge 1 commit into
base: RC_2_0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ file_mapping::file_mapping(file_handle file, open_mode_t const mode, std::int64_
#if TORRENT_USE_MADVISE
if (file_size > 0)
{
int const advise = ((mode & open_mode::random_access) ? 0 : MADV_SEQUENTIAL)
int const advise = ((mode & open_mode::random_access) ? MADV_RANDOM : MADV_SEQUENTIAL)
#ifdef MADV_DONTDUMP
// on versions of linux that support it, ask for this region to not be
// included in coredumps (mostly to make the coredumps more manageable
Expand All @@ -200,8 +200,7 @@ file_mapping::file_mapping(file_handle file, open_mode_t const mode, std::int64_
| MADV_NOCORE
#endif
;
if (advise != 0)
madvise(m_mapping, static_cast<std::size_t>(m_size), advise);
madvise(m_mapping, static_cast<std::size_t>(m_size), advise);
}
#endif
}
Expand Down