Skip to content

Windows: heavy disk reads while downloading with SetFileValidData() enabled (libtorrent 2.1.1) #8760

Description

@pulbitz

What happens

On Windows, while downloading a multi-file torrent, my disk gets almost as much read traffic as write traffic, even though I'm only downloading. The reads are on the very files that are being written at that moment.

This happens with libtorrent 2.1.1. With a libtorrent 1.2 based build, the same torrent on the same drive with the same settings produced only about a fifth of the disk reads.

Downloading at about 50 MB/s, Resource Monitor (Disk tab) shows:

Process Read Write
qbittorrent.exe 38.1 MB/s 0
System 0 35.8 MB/s

Per file, for the torrent being downloaded:

File Read Write Read / Write
1 31.8 MB/s 24.9 MB/s 1.27
2 6.4 MB/s 5.5 MB/s 1.16
3 0 5.3 MB/s -

These are real disk reads, not cache hits — the drive sat at 88% active time.
My upload rate was low at the time, so this isn't seeding traffic.

Environment

  • Tested with a qBittorrent 5.3.0alpha1 GitHub Actions build using libtorrent 2.1.1
  • OS cache enabled for both read and write, disk queue size 100 MiB, pread/pwrite disk IO type
  • Windows 11, NTFS with 4 KiB clusters, HDD
  • "Pre-allocate disk space for all files" enabled
  • Running qBittorrent as administrator, so SetFileValidData() succeeds

Workaround

Turning off "Pre-allocate disk space for all files" so the files are created sparse, and no longer starting qBittorrent as administrator, means SetFileValidData() is never used. With that, the reads almost completely disappear at the same download speed.

With libtorrent 1.2 this was fine as it was.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions