qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
26.99k stars 3.88k forks source link

Configurable save statistics interval #21285

Open jibwf opened 2 weeks ago

jibwf commented 2 weeks ago

Suggestion

I am using qBittorrent on a low end device, I want to minimize IO write or HDD spin up. qBittorrent-data.conf write every 15mins, request option to disable it or set interval

Use case

Anyone want to reduce SSD write or spin down HDD

Extra info/examples/attachments

No response

inphobia commented 2 weeks ago

i don't see no qbittorrent-data.conf on my system, only a .ini (5.1.0alpha).

however, if it's contents aren't important or you're happy with it being saved once daily, you could work around this on linux (and most likely macos), if you're file is 1kb like mine: create a tmpfs (or use an existing one, see which fs is a tmpfs using mount) and softlink (ln -s) your conf to a location on the tmpfs. tmpfs starts clear every reboot, so either remember to create the file after a reboot on the tmpfs, start qbittorrent with a shellscript that does this for you, or add it somewhere in systemd's startup workflow. for backups just create a cronjob that copies it to persistent storage at whateever interval you choose.

dunno how qbittorrent will like it if you remove write access to the file, that could be a temp workaround on all platforms.

jibwf commented 2 weeks ago

Thanks @inphobia for quick comments. I tried set read only, but qbittorrent will create a new qbittorrent-data.conf and delete old qbittorrent-data.conf, so it did not work. I will try tmpfs workaround.

jibwf commented 2 weeks ago

I think it is enough to save statistic when qbittorrent exit.

jibwf commented 2 weeks ago

https://github.com/qbittorrent/qBittorrent/commit/4d3672f8944e461f06720f4df89fa9bd34c8a57d

In this change, Save statistics every 15min and only if there was new traffic. But from my testing, it will save every 15min even no any new upload or download.

@sledgehammer999

inphobia commented 2 weeks ago

it's hardcoded to check every 15 minutes: https://github.com/qbittorrent/qBittorrent/blob/9d0fa213bed6172d269afd7364769eca66f16631/src/base/bittorrent/sessionimpl.cpp#L115

but if m_isStatisticsDirty isn't set it should not save: https://github.com/qbittorrent/qBittorrent/blob/9d0fa213bed6172d269afd7364769eca66f16631/src/base/bittorrent/sessionimpl.cpp#L6213-L6216

the default is false & can only be set to true here: https://github.com/qbittorrent/qBittorrent/blob/9d0fa213bed6172d269afd7364769eca66f16631/src/base/bittorrent/sessionimpl.cpp#L5969-L5979

so it should only save of you uploaded or downloaded at least 1 byte (which also seems to include ip overhead), and that's as far back as o read the code, so something must have changed one of those values. perhaps just an incoming connection that didn't even complete? dunno, cpp ain't my forte so finding all options will take to long for me.

jibwf commented 2 weeks ago

Thank you very much for taking the time to review the code. I hope we can make it an option in the future.

jibwf commented 1 week ago

I paused all seeds, the qbittorrent-data.conf still write every 15 mins.

stalkerok commented 1 week ago

qBittorrent takes traffic overhead into account, so the statistics will be updated even if you don't have any torrents.

jibwf commented 1 week ago

Really Cool! Thanks for your PR! @burnerelu