From 7cc14bda520f0062b0237e6c49919bc811488685 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 17 Apr 2024 04:06:49 +0300 Subject: [PATCH] chore: remove upload boost Increasing chunks size, `kMaxUploadPerSession`, etc. don't change the speed, only if slows down. Maybe changing `kAcceptAsFastIfTotalAtLeast` could give a boost. Didn't check. In some circumstances, speed could be worse than on the AyuGram `v4.16` with boost, but it's rare. But the upload speed is good, so upload boost removed. --- Telegram/SourceFiles/ayu/ayu_settings.cpp | 6 ----- Telegram/SourceFiles/ayu/ayu_settings.h | 5 ---- .../ayu/ui/settings/settings_ayu.cpp | 23 ------------------- .../ayu/utils/telegram_helpers.cpp | 6 +---- .../SourceFiles/core/crash_report_window.cpp | 2 +- .../data/data_message_reactions.cpp | 2 +- .../mtproto/dedicated_file_loader.cpp | 14 ++--------- .../mtproto/dedicated_file_loader.h | 2 +- Telegram/SourceFiles/storage/file_upload.cpp | 4 ++-- 9 files changed, 8 insertions(+), 56 deletions(-) diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index c00f8f549..c440f9fa3 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -202,8 +202,6 @@ AyuGramSettings::AyuGramSettings() { collapseSimilarChannels = true; hideSimilarChannels = false; - uploadSpeedBoost = false; - disableNotificationsDelay = false; localPremium = false; copyUsernameAsLink = true; @@ -329,10 +327,6 @@ void AyuGramSettings::set_hideSimilarChannels(bool val) { hideSimilarChannels = val; } -void AyuGramSettings::set_uploadSpeedBoost(bool val) { - uploadSpeedBoost = val; -} - void AyuGramSettings::set_disableNotificationsDelay(bool val) { disableNotificationsDelay = val; } diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index 1530d464c..a7d954e86 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -35,8 +35,6 @@ public: bool collapseSimilarChannels; bool hideSimilarChannels; - bool uploadSpeedBoost; - bool disableNotificationsDelay; bool localPremium; bool copyUsernameAsLink; @@ -95,8 +93,6 @@ public: void set_collapseSimilarChannels(bool val); void set_hideSimilarChannels(bool val); - void set_uploadSpeedBoost(bool val); - void set_disableNotificationsDelay(bool val); void set_localPremium(bool val); void set_copyUsernameAsLink(bool val); @@ -152,7 +148,6 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( disableCustomBackgrounds, collapseSimilarChannels, hideSimilarChannels, - uploadSpeedBoost, disableNotificationsDelay, localPremium, copyUsernameAsLink, diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp index 5c4a71634..42fd46b7c 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp @@ -667,29 +667,6 @@ void SetupQoLToggles(not_null container) { AddDivider(container); AddSkip(container); - AddButtonWithIcon( - container, - tr::ayu_UploadSpeedBoostPC(), - st::settingsButtonNoIcon - )->toggleOn( - rpl::single(settings->uploadSpeedBoost) - )->toggledValue( - ) | rpl::filter( - [=](bool enabled) - { - return (enabled != settings->uploadSpeedBoost); - }) | start_with_next( - [=](bool enabled) - { - settings->set_uploadSpeedBoost(enabled); - AyuSettings::save(); - }, - container->lifetime()); - - AddSkip(container); - AddDivider(container); - AddSkip(container); - AddButtonWithIcon( container, tr::ayu_DisableNotificationsDelay(), diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index f6daa74ae..c93f8171c 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -492,11 +492,7 @@ QString getMediaDC(not_null message) { int getScheduleTime(int64 sumSize) { auto time = 12; - - const auto settings = &AyuSettings::getInstance(); - const auto multiplier = settings->uploadSpeedBoost ? 0.7 : 4.5; - time += (int) std::ceil(std::max(6.0, std::ceil(sumSize / 1024.0 / 1024.0 * multiplier))) + 1; - + time += (int) std::ceil(std::max(6.0, std::ceil(sumSize / 1024.0 / 1024.0 * 0.7))) + 1; return time; } diff --git a/Telegram/SourceFiles/core/crash_report_window.cpp b/Telegram/SourceFiles/core/crash_report_window.cpp index bd98002e3..69f0cf21e 100644 --- a/Telegram/SourceFiles/core/crash_report_window.cpp +++ b/Telegram/SourceFiles/core/crash_report_window.cpp @@ -443,7 +443,7 @@ LastCrashedWindow::LastCrashedWindow( }); _saveReport.setText(u"SAVE TO FILE"_q); connect(&_saveReport, &QPushButton::clicked, [=] { saveReport(); }); - _getApp.setText(u"GET THE LATEST OFFICIAL VERSION OF AYUGRAM DESKTOP"_q); + _getApp.setText(u"GET THE LATEST VERSION OF AYUGRAM DESKTOP"_q); connect(&_getApp, &QPushButton::clicked, [=] { QDesktopServices::openUrl(u"https://github.com/AyuGram/AyuGramDesktop"_q); }); diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index f74552066..8e4d65cc6 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -39,7 +39,7 @@ namespace Data { namespace { constexpr auto kRefreshFullListEach = 60 * 60 * crl::time(1000); -constexpr auto kPollEach = 10 * crl::time(1000); +constexpr auto kPollEach = 15 * crl::time(1000); constexpr auto kSizeForDownscale = 64; constexpr auto kRecentRequestTimeout = 10 * crl::time(1000); constexpr auto kRecentReactionsLimit = 40; diff --git a/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp b/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp index c8d9524b6..850d5c6c1 100644 --- a/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp +++ b/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp @@ -13,10 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "base/call_delayed.h" -// AyuGram includes -#include "ayu/ayu_settings.h" - - namespace MTP { namespace { @@ -84,12 +80,6 @@ std::optional ParseFile( return DedicatedLoader::File{ name, size, fields.vdc_id().v, location }; } -int RequestCount() { - const auto settings = &AyuSettings::getInstance(); - static const auto count = settings->uploadSpeedBoost ? 8 : 2; - return count; -} - } // namespace WeakInstance::WeakInstance(base::weak_ptr session) @@ -320,7 +310,7 @@ void DedicatedLoader::startLoading() { } void DedicatedLoader::sendRequest() { - if (_requests.size() >= RequestCount() || _offset >= _size) { + if (_requests.size() >= kRequestsCount || _offset >= _size) { return; } const auto offset = _offset; @@ -336,7 +326,7 @@ void DedicatedLoader::sendRequest() { MTP::updaterDcId(_dcId)); _offset += kChunkSize; - if (_requests.size() < RequestCount()) { + if (_requests.size() < kRequestsCount) { base::call_delayed(kNextRequestDelay, this, [=] { sendRequest(); }); } } diff --git a/Telegram/SourceFiles/mtproto/dedicated_file_loader.h b/Telegram/SourceFiles/mtproto/dedicated_file_loader.h index eee56303a..4c173608f 100644 --- a/Telegram/SourceFiles/mtproto/dedicated_file_loader.h +++ b/Telegram/SourceFiles/mtproto/dedicated_file_loader.h @@ -135,7 +135,7 @@ private: void gotPart(int offset, const MTPupload_File &result); Fn failHandler(); - static constexpr auto kRequestsCount = 2; + static constexpr auto kRequestsCount = 6; static constexpr auto kNextRequestDelay = crl::time(20); std::deque _requests; diff --git a/Telegram/SourceFiles/storage/file_upload.cpp b/Telegram/SourceFiles/storage/file_upload.cpp index 95c4b0a1b..9e00afd1c 100644 --- a/Telegram/SourceFiles/storage/file_upload.cpp +++ b/Telegram/SourceFiles/storage/file_upload.cpp @@ -46,8 +46,8 @@ constexpr auto kDocumentUploadPartSize3 = 256 * 1024; // 512kb for large document ( <= 1500mb ) constexpr auto kDocumentUploadPartSize4 = 512 * 1024; -// One part each half second, if not uploaded faster. -constexpr auto kUploadRequestInterval = crl::time(250); +// One part each 200ms, if not uploaded faster. +constexpr auto kUploadRequestInterval = crl::time(200); // How much time without upload causes additional session kill. constexpr auto kKillSessionTimeout = 15 * crl::time(1000);