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

don't hint POSIX_FADV_RANDOM #7758

Merged
merged 1 commit into from
Oct 20, 2024
Merged

don't hint POSIX_FADV_RANDOM #7758

merged 1 commit into from
Oct 20, 2024

Conversation

arvidn
Copy link
Owner

@arvidn arvidn commented Oct 20, 2024

Normal piece sizes, of 2 or 4 MiB, probably warrants read-ahead. Some antecdotes suggests this improve read speed in some circumstances.

The use of the internal open mode flag random_access is really used to hint sequential access, for when checking files. This patch, therefore, renames the flag to sequential_access and makes it mean that instead.

This is an internal flag so doesn't affect the user facing API.

@HanabishiRecca
Copy link
Contributor

Just for the context, from posix_fadvise(2):

Under Linux, POSIX_FADV_NORMAL sets the readahead window to the default size for the backing device; POSIX_FADV_SEQUENTIAL doubles this size, and POSIX_FADV_RANDOM disables file readahead entirely.

@@ -142,7 +142,7 @@ namespace {
aux::open_mode_t file_mode_for_job(aux::mmap_disk_job* j)
{
aux::open_mode_t ret = aux::open_mode::read_only;
if (!(j->flags & disk_interface::sequential_access)) ret |= aux::open_mode::random_access;
if (!(j->flags & disk_interface::sequential_access)) ret |= aux::open_mode::sequential_access;
Copy link
Contributor

@HanabishiRecca HanabishiRecca Oct 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to remove the ! here. It makes logic to be reversed.
And confirmed by testing, I see regular reads using 2x readahead size, but torrent re-checking use 1x instead.

Suggested change
if (!(j->flags & disk_interface::sequential_access)) ret |= aux::open_mode::sequential_access;
if (j->flags & disk_interface::sequential_access) ret |= aux::open_mode::sequential_access;

@arvidn arvidn force-pushed the random-access-hint branch from 12e7141 to c3ebead Compare October 20, 2024 18:37
…ably warrants read-ahead. Some antecdotes suggests this improve read speed in some circumstances
@arvidn arvidn force-pushed the random-access-hint branch from c3ebead to ac5e48d Compare October 20, 2024 20:40
@arvidn arvidn merged commit 07b2574 into RC_2_0 Oct 20, 2024
41 of 42 checks passed
@arvidn arvidn deleted the random-access-hint branch October 20, 2024 23:25
@arvidn
Copy link
Owner Author

arvidn commented Oct 20, 2024

@HanabishiRecca thanks for your testing and review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants