From c9e852dc2c37b15f51c4edcd794e359787679897 Mon Sep 17 00:00:00 2001 From: stickz Date: Tue, 25 Jun 2024 08:55:26 -0400 Subject: [PATCH] rTorrent: Add disk space preallocation environment variable 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. --- README.md | 23 +++++++++++++++++++++++ rootfs/etc/cont-init.d/03-config.sh | 2 ++ rootfs/tpls/etc/rtorrent/.rtlocal.rc | 3 +++ 3 files changed, 28 insertions(+) diff --git a/README.md b/README.md index ce46fca4..7928c0a0 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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: diff --git a/rootfs/etc/cont-init.d/03-config.sh b/rootfs/etc/cont-init.d/03-config.sh index c6558d64..e3c01252 100644 --- a/rootfs/etc/cont-init.d/03-config.sh +++ b/rootfs/etc/cont-init.d/03-config.sh @@ -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} @@ -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..." diff --git a/rootfs/tpls/etc/rtorrent/.rtlocal.rc b/rootfs/tpls/etc/rtorrent/.rtlocal.rc index b9b502d7..e7deb524 100644 --- a/rootfs/tpls/etc/rtorrent/.rtlocal.rc +++ b/rootfs/tpls/etc/rtorrent/.rtlocal.rc @@ -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_*