New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add checking_mem_usage option to AdvancedSettings #9373
Add checking_mem_usage option to AdvancedSettings #9373
Conversation
src/gui/advancedsettings.h
Outdated
@@ -59,7 +59,7 @@ private slots: | |||
template <typename T> void addRow(int row, const QString &rowText, T *widget); | |||
|
|||
QLabel labelQbtLink, labelLibtorrentLink; | |||
QSpinBox spinBoxAsyncIOThreads, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen, | |||
QSpinBox spinBoxCheckingMemUsage, spinBoxAsyncIOThreads, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxMaxHalfOpen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're placing the new option after "async IO threads", please do it here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do.
src/gui/advancedsettings.cpp
Outdated
spinBoxCheckingMemUsage.setMinimum(1); | ||
spinBoxCheckingMemUsage.setMaximum(256000); | ||
spinBoxCheckingMemUsage.setValue(session->checkingMemUsage()); | ||
addRow(CHECKING_MEM_USAGE, tr("Checking memory usage"), &spinBoxCheckingMemUsage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name a bit too vague, maybe "Outstanding memory blocks when checking torrents".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but wouldn't it also be useful to also mention that each block is 16 KiB? Example:
"Outstanding 16 KiB memory blocks when checking torrents"
or
"Outstanding memory when checking torrents (16 KiB blocks)"
or
"Outstanding memory (16 KiB blocks) when checking torrents"
Or is it too much information/confusing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but wouldn't it also be useful to also mention that each block is 16 KiB?
Sure, or even better: let users specify in MiB instead of number of blocks, sort of like the "Disk cache" option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will make that change and set the text to "Outstanding memory when checking torrents"
Recently I saw libtorrent has increased its default value to 1024, do you still see improvements when you tune this number even higher? Just curious. |
Currently I do not have a machine that I can test the effect of this setting on. However, according to #9061, rechecking speeds have increased as a result of recent patches to libtorrent, but not to optimal levels (as I understand it). This PR will make it easier for people to test rechecking speed while fiddling with Even if it turns out that 1024 is not the ideal default value for qBittorrent, we will now be able to easily change it. |
Let's just follow libtorrent default for now. |
Sounds good. |
e184293
to
6e72a2e
Compare
@Chocobo1 Addressed review comments. I need advice on the maximum allowed value for checking memory for 32-bit architectures. Currently, I set it to 128 MiB, because as I understand it, this will be competing with disk cache + program data for 2 GiB of RAM. The max for 64-bit architectures is currently 4 GiB as previously (~256000 16 KiB blocks). Is this value sane or should I set it higher? |
@FranciscoPombal: Some systems have more memory than others. Setting the max to 32 or 64 GB (the highest RAM consumer systems can generally use)—accompanied by a warning tooltip that this value needs to be significantly less than system memory—seems reasonable to me. |
@LordNyriox Anyway, I agree on setting the max higher, to something like 64 GiB (there are, indeed, enthusiast consumer machines sporting 128 GiB of RAM nowadays), even though that is well into diminishing returns territory (for now...). |
@Chocobo1 I remember that in previous versions recheck was sequential. I don't remember exactly the version in which this behaviour was changed. Sequential rechecking is (always?) better than concurrent, because even though it might not make much or any difference at all for systems with SSDs, the former is much faster in systems with HDDs. |
32-bit qBittorrent should use the same max-memory strategy as 64-bit. In Windows systems (both x86 and x64), the maximum possible memory available to any 32-bit program, is 4 GB. |
Instead of separating values for different architectures, I would just go for 1GB for both, even high performance seeding mode in libtorrent is merely using 32 MB: arvidn/libtorrent@70d6432 |
I am not sure, IIRC related code wasn't changed for some time, someone might need to check it again. |
IIRC there isn't an option that we can set. |
4 GiB vs 2 GiB maximum memory available depends on whether or not the process is "large address aware". I wasn't sure that was the case for qBittorrent, so I went with the conservative number.
Ok. I will change the limit to 1 GiB for both. If someone then benchmarks and finds that there is still scaling near the 1 GiB mark, that would warrant a bump.
I see no problem in checking concurrently if two torrents are on different physical disks, but can libtorrent even distinguish different partitions from different physical disks? (pinging @arvidn) Plus, users reporting these issues are saying that it happens for torrents on the same disk anyway. |
About the sequential/concurrent hash rechecks. I just checked libtorrent docs. From
The default value is set to 1. I did a search on qbt code and we don't change this field. I wonder how some users see concurrent hash rechecks then!?!? |
@sledgehammer999 Maybe in the following weeks I will have the means to attempt to reproduce the behaviour on the latest version. |
@sledgehammer999, @FranciscoPombal:
More specifically, the problem seems to affect any build of qBittorrent that uses Libtorrent 1.1.x (instead of 1.0.x). Just try @Gelmir's old 64-bit qBittorrent builds, if you do not believe me. Most of those builds provided both Libtorrent1.0 and Libtorrent1.1 variants (which were otherwise identical). I ran into simultaneous Recheck issues every time I used a 1.1.x build. |
Out of curiosity I tried it myself. 2 big torrents on the same physical disk recheck sequentially. Adding a 3rd one for recheck which resides on another physical disk makes it recheck concurrently with the one checking from the other disk. |
Good point.
Have you tried with more than 2 torrents on the same physical disk? it would not be unreasonable to think that the problem maybe only manifests itself with >2 torrents. |
@FranciscoPombal, @sledgehammer999:
I have (at various times, using the builds linked previously). And the behavior described by @sledgehammer999, also affected 3+ torrents on the same disk. @arvidn: Any input on this subject? |
src/gui/advancedsettings.cpp
Outdated
@@ -151,6 +152,8 @@ void AdvancedSettings::saveAdvancedSettings() | |||
// Async IO threads | |||
session->setAsyncIOThreads(spinBoxAsyncIOThreads.value()); | |||
#endif | |||
// Checking Memor Usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Memor" -> "Memory"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix this typo
if a torrent is not auto-managed, it is not subject to the |
@arvidn: What about when 3+ torrents are simultaneously marked for rechecking? That seems to be when the bug triggers. When only 2 torrents are marked for rechecking, they recheck sequentially (as intended). |
This is it.
In my above post, the 3rd torrent that I tried for rechecking was paused. In qbt everything explicitly paused is not auto-managed. That's why that torrent started checking concurrently with the other one. |
@sledgehammer999, @arvidn: Just an FYI, some cautious users (such as myself) may prefer to only trigger rechecking on "paused" torrents. Is there a reasonable way to disable "concurrent" rechecking on those? |
yes, set the stop-when-ready flag on the torrent before starting the check. |
what occurs to me is that to check a paused torrent, and have it still be paused after the check, still has a race condition. There is no way to start the check and set the auto-managed flag atomically. if you set the auto-managed flag first, there's a risk the torrent may start downloading for a split second, until the recheck call is made. If you start the rechecking first, it will start checking for a split second, until the auto managed flag is set and it's queued (assuming there's another torrent being checked already). The latter is probably less severe. |
Internally we track if torrent is paused. If yes, we set upload_mode and resume it without automanage. Immediately we issue force recheck. On recheck completion, we pause it and take it out of upload mode. |
I forgot to add that theoritically we could ourselves(qbt) keep count of the rechecking torrents and preserve the limit before issuing the recheck command. |
aa862c6
to
61e03e7
Compare
Addressed review comments, rebased and squashed commits. |
src/base/bittorrent/session.h
Outdated
@@ -377,6 +377,8 @@ namespace BitTorrent | |||
void setAnnounceToAllTiers(bool val); | |||
int asyncIOThreads() const; | |||
void setAsyncIOThreads(int num); | |||
int checkingMemUsage() const; | |||
void setCheckingMemUsage(int num); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the parameter is num
while at definition is size
, you should use the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fixed
61e03e7
to
f4806ec
Compare
Addressed review comments and squashed commits. |
@glassez |
f4806ec
to
74be5d9
Compare
Thank you! |
Adds a spinbox in advanced options to change the libtorrent setting
checking_mem_usage
.Potential usefulness: refer to discussion at #9061