Skip to content

Commit

Permalink
Expose librepo max_downloads_per_mirror configuration
Browse files Browse the repository at this point in the history
In many cases the librepo default of 3 concurrent downloads per mirror
is sufficient, as there are multiple mirrors, and the max of 3 per
mirror is cumulative up until max_parallel_downloads. However, in some
situations you don't necessarily want to have other mirrors, and want to
have more than 3 parallel downloads.

Such a situation could be where not all mirrors have equal cost, and can
handle more simultaneous downloads to saturate the available network
bandwidth - so it's beneficial to only list the one mirror in the
mirrorlist, and up the maximum number of parallel downloads.

= changelog =
msg: Expose librepo max_downloads_per_mirror config option
type: enhancement
  • Loading branch information
stewartsmith authored and Conan-Kudo committed Aug 19, 2022
1 parent 388e769 commit 6744080
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libdnf/conf/ConfigMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class ConfigMain::Impl {

OptionSeconds timeout{30};
OptionNumber<std::uint32_t> max_parallel_downloads{3, 1};
OptionNumber<std::uint32_t> max_downloads_per_mirror{3, 1};
OptionSeconds metadata_expire{60 * 60 * 48};
OptionString sslcacert{""};
OptionBool sslverify{true};
Expand Down Expand Up @@ -507,6 +508,7 @@ ConfigMain::Impl::Impl(Config & owner)
owner.optBinds().add("throttle", throttle);
owner.optBinds().add("timeout", timeout);
owner.optBinds().add("max_parallel_downloads", max_parallel_downloads);
owner.optBinds().add("max_downloads_per_mirror", max_downloads_per_mirror);
owner.optBinds().add("metadata_expire", metadata_expire);
owner.optBinds().add("sslcacert", sslcacert);
owner.optBinds().add("sslverify", sslverify);
Expand Down Expand Up @@ -628,6 +630,7 @@ OptionEnum<std::string> & ConfigMain::ip_resolve() { return pImpl->ip_resolve; }
OptionNumber<float> & ConfigMain::throttle() { return pImpl->throttle; }
OptionSeconds & ConfigMain::timeout() { return pImpl->timeout; }
OptionNumber<std::uint32_t> & ConfigMain::max_parallel_downloads() { return pImpl->max_parallel_downloads; }
OptionNumber<std::uint32_t> & ConfigMain::max_downloads_per_mirror() { return pImpl->max_downloads_per_mirror; }
OptionSeconds & ConfigMain::metadata_expire() { return pImpl->metadata_expire; }
OptionString & ConfigMain::sslcacert() { return pImpl->sslcacert; }
OptionBool & ConfigMain::sslverify() { return pImpl->sslverify; }
Expand Down
1 change: 1 addition & 0 deletions libdnf/conf/ConfigMain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class ConfigMain : public Config {
OptionNumber<float> & throttle();
OptionSeconds & timeout();
OptionNumber<std::uint32_t> & max_parallel_downloads();
OptionNumber<std::uint32_t> & max_downloads_per_mirror();
OptionSeconds & metadata_expire();
OptionString & sslcacert();
OptionBool & sslverify();
Expand Down
3 changes: 3 additions & 0 deletions libdnf/conf/ConfigRepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ConfigRepo::Impl {
OptionChild<OptionNumber<float> > throttle{mainConfig.throttle()};
OptionChild<OptionSeconds> timeout{mainConfig.timeout()};
OptionChild<OptionNumber<std::uint32_t> > max_parallel_downloads{mainConfig.max_parallel_downloads()};
OptionChild<OptionNumber<std::uint32_t> > max_downloads_per_mirror{mainConfig.max_downloads_per_mirror()};
OptionChild<OptionSeconds> metadata_expire{mainConfig.metadata_expire()};
OptionNumber<std::int32_t> cost{1000};
OptionNumber<std::int32_t> priority{99};
Expand Down Expand Up @@ -155,6 +156,7 @@ ConfigRepo::Impl::Impl(Config & owner, ConfigMain & mainConfig)
owner.optBinds().add("throttle", throttle);
owner.optBinds().add("timeout", timeout);
owner.optBinds().add("max_parallel_downloads", max_parallel_downloads);
owner.optBinds().add("max_downloads_per_mirror", max_downloads_per_mirror);
owner.optBinds().add("metadata_expire", metadata_expire);
owner.optBinds().add("cost", cost);
owner.optBinds().add("priority", priority);
Expand Down Expand Up @@ -211,6 +213,7 @@ OptionChild<OptionEnum<std::string> > & ConfigRepo::ip_resolve() { return pImpl-
OptionChild<OptionNumber<float> > & ConfigRepo::throttle() { return pImpl->throttle; }
OptionChild<OptionSeconds> & ConfigRepo::timeout() { return pImpl->timeout; }
OptionChild<OptionNumber<std::uint32_t> > & ConfigRepo::max_parallel_downloads() { return pImpl->max_parallel_downloads; }
OptionChild<OptionNumber<std::uint32_t> > & ConfigRepo::max_downloads_per_mirror() { return pImpl->max_downloads_per_mirror; }
OptionChild<OptionSeconds> & ConfigRepo::metadata_expire() { return pImpl->metadata_expire; }
OptionNumber<std::int32_t> & ConfigRepo::cost() { return pImpl->cost; }
OptionNumber<std::int32_t> & ConfigRepo::priority() { return pImpl->priority; }
Expand Down
1 change: 1 addition & 0 deletions libdnf/conf/ConfigRepo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ConfigRepo : public Config {
OptionChild<OptionNumber<float> > & throttle();
OptionChild<OptionSeconds> & timeout();
OptionChild<OptionNumber<std::uint32_t> > & max_parallel_downloads();
OptionChild<OptionNumber<std::uint32_t> > & max_downloads_per_mirror();
OptionChild<OptionSeconds> & metadata_expire();
OptionNumber<std::int32_t> & cost();
OptionNumber<std::int32_t> & priority();
Expand Down
2 changes: 2 additions & 0 deletions libdnf/repo/Repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitBase()
handleSetOpt(h.get(), LRO_MAXMIRRORTRIES, static_cast<long>(maxMirrorTries));
handleSetOpt(h.get(), LRO_MAXPARALLELDOWNLOADS,
conf->max_parallel_downloads().getValue());
handleSetOpt(h.get(), LRO_MAXDOWNLOADSPERMIRROR,
conf->max_downloads_per_mirror().getValue());

LrUrlVars * vars = NULL;
vars = lr_urlvars_set(vars, MD_TYPE_GROUP_GZ, MD_TYPE_GROUP);
Expand Down
10 changes: 10 additions & 0 deletions python/hawkey/tests/tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ def test_cost_assignment(self):
with self.assertRaises(TypeError):
r2.cost = '4'

def test_max_parallel_downloads(self):
r = hawkey.Repo("fog")
r.max_parallel_downloads = 10
self.assertEqual(10, r.max_parallel_downloads)

def test_max_downloads_per_mirror(self):
r = hawkey.Repo("fog")
r.max_downloads_per_mirror = 10
self.assertEqual(10, r.max_downloads_per_mirror)

def test_str_assignment(self):
r = hawkey.Repo('fog')
with self.assertRaises(TypeError):
Expand Down

0 comments on commit 6744080

Please sign in to comment.