Skip to content
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

libtorrent session options #3235

Merged
merged 8 commits into from
Aug 24, 2017
Merged

Conversation

Chocobo1
Copy link
Member

@Chocobo1 Chocobo1 commented Jun 16, 2015

>>First post outdated, see #3235 (comment) <<

I found some interesting options when reading libtorrent's document:

  • guided_read_cache: [default off]
    Also see: tuning#disk-cache

    The idea being that slow peers don't use up a disproportional amount of space in the cache

    This looks promising.

  • prefer_tcp: [default off]
    Also see: tuning#utp-tcp-mixed-mode
    Since there are issues with peer_proportional in the past, then just use prefer_tcp in all cases.
    I can't see why this should be depending on rate_limit_utp.

  • use_parole_mode: [default off]
    Maybe give a hashcheck-failed peer another chance before banning.

new

@Chocobo1
Copy link
Member Author

I think this PR will have a better chance of getting merged by making these options available in "advanced options". Maybe later when I find time.

@Chocobo1 Chocobo1 force-pushed the session_option branch 4 times, most recently from 518107c to 3e025e8 Compare February 2, 2016 08:20
@Chocobo1
Copy link
Member Author

Chocobo1 commented Feb 2, 2016

Commits & first post updated.

@@ -1403,6 +1403,16 @@ void Preferences::setOsCache(bool enable)
setValue("Preferences/Advanced/osCache", enable);
}

bool Preferences::getGuidedReadCache() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferences is deprecated now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole PR is outdated, I'm not even sure if @sledgehammer999 would approve this...

@Chocobo1
Copy link
Member Author

@Chocobo1: ?

I plan to resurrect it after I'm done with other things, it's very low prio now.

@sledgehammer999
Copy link
Member

@Chocobo1 FYI, this is approved. You can resurrect and merge. And probably you don't need 3 separate commits.

@sledgehammer999
Copy link
Member

@Chocobo1 I think guided_read_cache and use_parole_mode can always be on. IMO, they don't need a user setting.

@Chocobo1
Copy link
Member Author

I think guided_read_cache and use_parole_mode can always be on. IMO, they don't need a user setting.

libtorrent made use_parole_mode = true as default, I'll drop this one.
As for guided_read_cache, it's disabled by default in libtorrent and might not get enough testing.
IMO make it tunable is better.

FYI, this is approved. You can resurrect and merge. And probably you don't need 3 separate commits.

Now I plan to add some other options, I'll put out a PR first, then we can bargain.

@Chocobo1
Copy link
Member Author

@sledgehammer999 @glassez
I've updated this PR and now it add options for the following settings:

guided_read_cache
mixed_mode_algorithm
allow_multiple_connections_per_ip
choking_algorithm
seed_choking_algorithm
suggest_mode
send_buffer_watermark
send_buffer_low_watermark
send_buffer_watermark_factor

Copy link
Member

@sledgehammer999 sledgehammer999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a final minor nitpick but 3 of your commit messages don't start with a capital letter like the others.

@@ -270,6 +270,7 @@ Session::Session(QObject *parent)
, m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY("MaxUploadsPerTorrent"), -1, lowerLimited(0, -1))
, m_isUTPEnabled(BITTORRENT_SESSION_KEY("uTPEnabled"), true)
, m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true)
, m_utpMixedMode(BITTORRENT_SESSION_KEY("utpMixedMode"), m_isUTPEnabled)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most existing installations are working today with prefer_tcp. So I would say the default here should be false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the name should be uTPMixedMode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the name should be uTPMixedMode

OK

So I would say the default here should be false.

Do you think we should also turn uTP off by default? otherwise, with uTP on + prefer_tcp, uTP would be useless in theory.


void Session::setChokingAlgorithm(bool mode)
{
if (mode == m_chokingAlgorithm)return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before return

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here, will push update later

@@ -187,6 +189,13 @@ void AdvancedSettings::saveAdvancedSettings()
// Tracker
session->setTrackerEnabled(cb_tracker_status.isChecked());
pref->setTrackerPort(spin_tracker_port.value());

// Choking algorithm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need the blank lines before the comments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove it.


settingsPack.set_int(libt::settings_pack::choking_algorithm,
chokingAlgorithm() ? libt::choking_algorithm_t::rate_based_choker : libt::choking_algorithm_t::fixed_slots_choker);
settingsPack.set_int(libt::settings_pack::seed_choking_algorithm, seedChokingAlgorithm());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seed_choking_algorithm is being set in the session constructor so you need to remove it from there too.

Copy link
Member Author

@Chocobo1 Chocobo1 Aug 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

// Send buffer watermark
spinSendBufferWatermark.setMinimum(1);
spinSendBufferWatermark.setMaximum(INT_MAX);
spinSendBufferWatermark.setSuffix(tr(" KB"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KiB.
Also shouldn't it be non-translatable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also shouldn't it be non-translatable?

fixed, will also fix other locations.

@Chocobo1 Chocobo1 force-pushed the session_option branch 2 times, most recently from 1b82f06 to 012b22f Compare August 12, 2017 13:59
@Chocobo1
Copy link
Member Author

@sledgehammer999
I think it's ready, the only thing left is #3235 (comment)

@sledgehammer999
Copy link
Member

I think it's ready, the only thing left is #3235 (comment)

Shit. I thought I had replied to this. Yes. No problem. Approved by me.
Now @glassez remains to revoke his block.

@@ -197,7 +223,7 @@ void AdvancedSettings::updateCacheSpinSuffix(int value)
if (value <= 0)
spin_cache.setSuffix(tr(" (auto)"));
else
spin_cache.setSuffix(tr(" MiB"));
spin_cache.setSuffix(" MiB");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this string isn't translatable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glassez: This was requested by @sledgehammer999

@sledgehammer999, why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a question.
Is it reasonable to have translatable units?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least some of the Cyrillic languages use transliterated abbreviations (e.g. "MіБ" for "MiB" in Ukrainian).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks, will fix it.

void Session::setGuidedReadCache(bool enabled)
{
if (enabled == m_guidedReadCache) return;
m_guidedReadCache = enabled;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add blank line before this one like in another setters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -314,6 +314,10 @@ namespace BitTorrent
void setForceProxyEnabled(bool enabled);
bool isProxyPeerConnectionsEnabled() const;
void setProxyPeerConnectionsEnabled(bool enabled);
bool chokingAlgorithm() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you provide originally enumerable setting as bool?
The same question is about mixed mode algorithm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both changed to int type.

@@ -330,6 +334,16 @@ namespace BitTorrent
void setDiskCacheTTL(uint ttl);
bool useOSCache() const;
void setUseOSCache(bool use);
bool guidedReadCache() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use naming convention for bool properties: isGuidedReadCacheUsed or isGuidedReadCacheEnabled.
The same comment is for other bool properties.

Copy link
Member

@glassez glassez Aug 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming Boolean Getters, Setters, and Properties
Finding good names for the getter and setter of a bool property is always a special pain. Should the getter be called checked() or isChecked()? scrollBarsEnabled() or areScrollBarEnabled()?

In Qt 4, we used the following guidelines for naming the getter function:

Adjectives are prefixed with is-. Examples:
isChecked()
isDown()
isEmpty()
isMovingEnabled()
However, adjectives applying to a plural noun have no prefix:
scrollBarsEnabled(), not areScrollBarsEnabled()
Verbs have no prefix and don't use the third person (-s):
acceptDrops(), not acceptsDrops()
allColumnsShowFocus()
Nouns generally have no prefix:
autoCompletion(), not isAutoCompletion()
boundaryChecking()
Sometimes, having no prefix is misleading, in which case we prefix with is-:
isOpenGLAvailable(), not openGL()
isDialog(), not dialog()
(From a function called dialog(), we would normally expect that it returns a QDialog.)
The name of the setter is derived from that of the getter by removing any is prefix and putting a set at the front of the name; for example, setDown() and setScrollBarsEnabled(). The name of the property is the same as the getter, but without the is prefix.

So useOSCache kind of makes sense. Even guidedReadCache can be used as bool property name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I jumped the gun here... the point is that if bool property has a name without is-/has- prefix it's not so clear it is correct or not. We need to check all new bool properties.

@Chocobo1
Copy link
Member Author

PR updated.

@Chocobo1 Chocobo1 force-pushed the session_option branch 2 times, most recently from 5ba34f9 to ed7bdb2 Compare August 15, 2017 06:52
@@ -299,6 +299,8 @@ Session::Session(QObject *parent)
, m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0)
, m_isForceProxyEnabled(BITTORRENT_SESSION_KEY("ForceProxy"), true)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), 0)
, m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY("SeedChokingAlgorithm"), 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value here should be 1. It was a request in the past to use fastest_upload by default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

Copy link
Member Author

@Chocobo1 Chocobo1 Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix

However, it feels weird because peer which has better download speed will always have higher priority to be served.

, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), 0)
, m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY("SeedChokingAlgorithm"), 0)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), 0, clampValue(0, 2))
, m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY("SeedChokingAlgorithm"), 0, clampValue(0, 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value here should be 1. It was a request in the past to use fastest_upload by default.

@@ -296,6 +317,8 @@ Session::Session(QObject *parent)
, m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0)
, m_isForceProxyEnabled(BITTORRENT_SESSION_KEY("ForceProxy"), true)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), 0, clampValue(0, 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChockingAlgorithm should be limited by 0 and 1, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see enum choking_algorithm_t in libtorrent doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in earlier commit you chose to not expose bittyrant_choker.
Was there a reason?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't mix interface of components of an application with interface of underlying library. If you allow users only two choices then Session::chockingAlgorithm property has only two possible values independently of the way it really implemented.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason?

libtorrent states its incomplete & untested.
Also read Q: Won’t BitTyrant hurt overall BitTorrent performance if everyone uses it?
in http://bittyrant.cs.washington.edu/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libtorrent states its incomplete & untested.
Also read Q: Won’t BitTyrant hurt overall BitTorrent performance if everyone uses it?
in http://bittyrant.cs.washington.edu/

+1.
Don't forget to rebase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't mix interface of components of an application with interface of underlying library

That won't be a problem after enums are deployed.

@glassez glassez added the Core label Aug 18, 2017
@Chocobo1
Copy link
Member Author

Updated.

Copy link
Member

@glassez glassez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last small comments. The rest LGTM.

@@ -282,6 +301,9 @@ Session::Session(QObject *parent)
, m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY("MaxUploadsPerTorrent"), -1, lowerLimited(0, -1))
, m_isUTPEnabled(BITTORRENT_SESSION_KEY("uTPEnabled"), true)
, m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true)
, m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), static_cast<BitTorrent::MixedModeAlgorithm>(m_isUTPEnabled.value())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have dependent default value here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, using ternary operator (instead of cast) would be more obvious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have dependent default value here?

Ah, damn it, I didn't realize until now... it doesn't need to depend on others.
Changed.

@Chocobo1
Copy link
Member Author

@evsh @sledgehammer999
Any comments?

@zeule
Copy link
Contributor

zeule commented Aug 23, 2017

Any comments?

No.

@Chocobo1 Chocobo1 merged commit 1afd5f7 into qbittorrent:master Aug 24, 2017
@Chocobo1 Chocobo1 deleted the session_option branch August 24, 2017 03:35
@Chocobo1
Copy link
Member Author

thanks to everyone

@Seeker2
Copy link

Seeker2 commented Oct 30, 2017

Was announce_to_all_tiers dropped because qBitTorrent lacks the GUI support for it?

Send upload piece suggestions cripples upload speed for some reason. I'm guessing it's an super/initial seeding type of feature to be used with low upload max?

prefer_tcp set to false also causes local peers to slow to almost nothing when internet uTP peers are connected even when LAN speeds are set to unlimited.

@sledgehammer999
Copy link
Member

@Seeker2 look at #7660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants