Skip to content

Commit

Permalink
rTorrent: Add disk space preallocation environment variable
Browse files Browse the repository at this point in the history
rTorrent stickz introduces a new feature where it's possible to pre-allocate disk space for an entire torrent whether it's downloaded or not. The benefit to place files in sequence on the file system for faster seeding. Potential disk throughput on HDDs is increased due to reduced random access.

This pull request documents the different types of disk space pre-allocation for rTorrent and allows the user to configure it based on their needs. It's disabled by default because it does not benefit SSDs. The user should manually configure as required.
  • Loading branch information
stickz committed Jun 27, 2024
1 parent ac02073 commit c9e852d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ___
* [Configure rTorrent session saving](#configure-rtorrent-session-saving)
* [Configure rTorrent tracker scrape](#rtorrent-tracker-scrape-patch)
* [Configure rTorrent send receive buffers](#rtorrent-send-receive-buffers)
* [Configure rTorrent disk space preallocation](#rtorrent-disk-space-preallocation)
* [Upgrade](#upgrade)
* [Contributing](#contributing)
* [License](#license)
Expand Down Expand Up @@ -141,6 +142,7 @@ Image: crazymax/rtorrent-rutorrent:latest
* `RT_INC_PORT`: Incoming connections (`network.port_range.set`, default `50000`)
* `RT_SEND_BUFFER_SIZE`: Sets default tcp wmem value (`network.send_buffer.size.set`, default `4M`)
* `RT_RECEIVE_BUFFER_SIZE`: Sets default tcp rmem value (`network.receive_buffer.size.set`, default `4M`)
* `RT_PREALLOCATE_TYPE`: Sets the type of [disk space preallocation](#rtorrent-disk-space-preallocation) (default `0`)

### ruTorrent

Expand Down Expand Up @@ -382,6 +384,27 @@ memory and speed conditions. The default values should not be increased, unless
both the memory and speed requirements are met. These values of system memory
are also recommended based on the port speed for rTorrent to reduce disk usage.

### rTorrent disk space preallocation

Preallocate disk space for contents of a torrent

* `RT_PREALLOCATE_TYPE`: Sets the type of disk space preallocation to use.

Acceptable values:
* `0 = disabled (default value)`
* `1 = enabled, allocate when a file is opened for write`
* `2 = enabled, allocate space for the whole torrent at once`

This feature is disabled by default becuase it only benefits HDDs.
By allocating files in sequence we can increase the read speed for seeding.

The first type "1" only allocates disk space for files which start downloading.
Use where disk space is more important than speed. Or you intend to download selective torrent files.

The second type "2" allocates disk space for the entire torrent, whether it's downloaded or not.
This method is faster than "1" becuase it reduces random reads for the entire torrent.
Use where speed is more important than disk space. Or you intend to download 100% of every torrent.

## Upgrade

To upgrade, pull the newer image and launch the container:
Expand Down
2 changes: 2 additions & 0 deletions rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ RT_SESSION_SAVE_SECONDS=${RT_SESSION_SAVE_SECONDS:-3600}
RT_TRACKER_DELAY_SCRAPE=${RT_TRACKER_DELAY_SCRAPE:-true}
RT_SEND_BUFFER_SIZE=${RT_SEND_BUFFER_SIZE:-4M}
RT_RECEIVE_BUFFER_SIZE=${RT_RECEIVE_BUFFER_SIZE:-4M}
RT_PREALLOCATE_TYPE=${RT_PREALLOCATE_TYPE:-0}

RU_REMOVE_CORE_PLUGINS=${RU_REMOVE_CORE_PLUGINS:-false}
RU_HTTP_USER_AGENT=${RU_HTTP_USER_AGENT:-Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0}
Expand Down Expand Up @@ -186,6 +187,7 @@ sed -e "s!@RT_LOG_LEVEL@!$RT_LOG_LEVEL!g" \
-e "s!@RT_TRACKER_DELAY_SCRAPE@!$RT_TRACKER_DELAY_SCRAPE!g" \
-e "s!@RT_SEND_BUFFER_SIZE@!$RT_SEND_BUFFER_SIZE!g" \
-e "s!@RT_RECEIVE_BUFFER_SIZE@!$RT_RECEIVE_BUFFER_SIZE!g" \
-e "s!@RT_PREALLOCATE_TYPE@!$RT_PREALLOCATE_TYPE!g" \
/tpls/etc/rtorrent/.rtlocal.rc > /etc/rtorrent/.rtlocal.rc
if [ "${RT_LOG_EXECUTE}" = "true" ]; then
echo " Enabling rTorrent execute log..."
Expand Down
3 changes: 3 additions & 0 deletions rootfs/tpls/etc/rtorrent/.rtlocal.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ trackers.delay_scrape = @RT_TRACKER_DELAY_SCRAPE@
network.send_buffer.size.set = @RT_SEND_BUFFER_SIZE@
network.receive_buffer.size.set = @RT_RECEIVE_BUFFER_SIZE@

# Configure preallocation feature for rTorrent client
system.file.allocate.set = @RT_PREALLOCATE_TYPE@

# Logging
## levels = critical error warn notice info debug
## groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
Expand Down

0 comments on commit c9e852d

Please sign in to comment.