arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.26k stars 997 forks source link

don't hint `POSIX_FADV_RANDOM` #7758

Closed arvidn closed 1 month ago

arvidn commented 1 month ago

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 commented 1 month ago

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.

arvidn commented 1 month ago

@HanabishiRecca thanks for your testing and review!