linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06110
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3067: less status updates to reduce CPU consumption
------------------------------------------------------------
revno: 3067
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2012-10-01 20:25:44 +0200
message:
less status updates to reduce CPU consumption
modified:
SConstruct
changelog.txt
win32/HubFrame.cpp
win32/HubFrame.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'SConstruct'
--- SConstruct 2012-09-24 15:58:29 +0000
+++ SConstruct 2012-10-01 18:25:44 +0000
@@ -35,6 +35,7 @@
# 4189: var init'd, unused
# 4244: possible loss of data on conversion
# 4290: exception spec ignored
+ # 4324: structure padded due to __declspec(align())
# 4355: "this" used in a constructor
# 4510: no default constructor
# 4512: assn not generated
@@ -42,7 +43,7 @@
# 4706: assignment within conditional expression
# 4800: converting from BOOL to bool
# 4996: fn unsafe, use fn_s
- 'common' : ['/W4', '/EHsc', '/Zi', '/Zm200', '/GR', '/FC', '/wd4100', '/wd4121', '/wd4127', '/wd4189', '/wd4244', '/wd4290', '/wd4355', '/wd4510', '/wd4512', '/wd4610', '/wd4706', '/wd4800', '/wd4996'],
+ 'common' : ['/W4', '/EHsc', '/Zi', '/Zm200', '/GR', '/FC', '/wd4100', '/wd4121', '/wd4127', '/wd4189', '/wd4244', '/wd4290', '/wd4324', '/wd4355', '/wd4510', '/wd4512', '/wd4610', '/wd4706', '/wd4800', '/wd4996'],
'debug' : ['/MDd'],
'release' : ['/MD', '/O2']
}
=== modified file 'changelog.txt'
--- changelog.txt 2012-09-29 12:29:21 +0000
+++ changelog.txt 2012-10-01 18:25:44 +0000
@@ -1,5 +1,6 @@
* Perf improvements using lock-free queues, requires P6 CPUs (poy)
* Reduce freezes when displaying file list dirs that contain lots of files (poy)
+* Less CPU consumption in large hubs (poy)
-- 0.800 2012-09-16 --
* [L#270107] Revamp favorite hub settings (poy)
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2012-09-10 22:14:27 +0000
+++ win32/HubFrame.cpp 2012-10-01 18:25:44 +0000
@@ -176,6 +176,8 @@
client(0),
url(url),
updateUsers(false),
+selCount(0),
+statusDirty(true),
waitingForPW(false),
resort(false),
confirmClose(true),
@@ -361,8 +363,9 @@
status->setText(STATUS_USERS, users.second + Text::toT(Util::toString(users.first)));
status->setToolTip(STATUS_USERS, users.second + str(TFN_("%1% user", "%1% users", users.first) % users.first));
- status->setText(STATUS_SHARED, getStatusShared());
- status->setText(STATUS_AVERAGE_SHARED, getStatusAverageShared());
+ auto shared = getStatusShared();
+ status->setText(STATUS_SHARED, shared.first);
+ status->setText(STATUS_AVERAGE_SHARED, shared.second);
}
void HubFrame::updateSecureStatus() {
@@ -392,7 +395,12 @@
callAsync([this] { execTasks(); });
}
- updateStatus();
+ auto prevSelCount = selCount;
+ selCount = users->countSelected();
+ if(statusDirty || selCount != prevSelCount) {
+ statusDirty = false;
+ updateStatus();
+ }
return true;
}
@@ -1016,16 +1024,6 @@
!(flags & ClientListener::FLAG_IS_SPAM) || !SETTING(FILTER_MESSAGES)); });
}
-tstring HubFrame::getStatusShared() const {
- int64_t available;
- if (users->countSelected() > 1) {
- available = users->forEachSelectedT(CountAvailable()).available;
- } else {
- available = std::for_each(userMap.begin(), userMap.end(), CountAvailable()).available;
- }
- return Text::toT(Util::formatBytes(available));
-}
-
size_t HubFrame::getUserCount() const {
size_t userCount = 0;
for(auto& i: userMap) {
@@ -1040,30 +1038,28 @@
auto userCount = getUserCount();
tstring textForUsers;
- if (users->countSelected() > 1)
- textForUsers += Text::toT(Util::toString(users->countSelected()) + "/");
- if (showUsers->getChecked() && users->size() < userCount)
- textForUsers += Text::toT(Util::toString(users->size()) + "/");
+ if(selCount > 1)
+ textForUsers += Text::toT(Util::toString(selCount) + "/");
+ auto filteredCount = users->size();
+ if(showUsers->getChecked() && filteredCount < userCount)
+ textForUsers += Text::toT(Util::toString(filteredCount) + "/");
return make_pair(userCount, textForUsers);
}
-tstring HubFrame::getStatusAverageShared() const {
+pair<tstring, tstring> HubFrame::getStatusShared() const {
int64_t available;
size_t userCount = 0;
- if (users->countSelected() > 1) {
+ if(selCount > 1) {
available = users->forEachSelectedT(CountAvailable()).available;
- userCount = users->countSelected();
+ userCount = selCount;
} else {
- available = std::for_each(userMap.begin(), userMap.end(), CountAvailable()).available;
- for(auto& i: userMap) {
- UserInfo* ui = i.second;
- if(!ui->isHidden())
- userCount++;
- }
+ available = users->forEachT(CountAvailable()).available;
+ userCount = users->size();
}
- return str(TF_("Average: %1%") % Text::toT(Util::formatBytes(userCount > 0 ? available / userCount : 0)));
+ return make_pair(Text::toT(Util::formatBytes(available)),
+ str(TF_("Average: %1%") % Text::toT(Util::formatBytes(userCount > 0 ? available / userCount : 0))));
}
void HubFrame::on(FavoriteManagerListener::UserAdded, const FavoriteUser& /*aUser*/) noexcept {
@@ -1153,6 +1149,8 @@
}
}
}
+
+ statusDirty = true;
}
bool HubFrame::userClick(const dwt::ScreenCoordinate& pt) {
@@ -1260,6 +1258,7 @@
SettingsManager::getInstance()->set(SettingsManager::GET_USER_INFO, checked);
layout();
+ statusDirty = true;
}
void HubFrame::handleMultiCopy(unsigned index) {
=== modified file 'win32/HubFrame.h'
--- win32/HubFrame.h 2012-07-01 18:41:13 +0000
+++ win32/HubFrame.h 2012-10-01 18:25:44 +0000
@@ -168,6 +168,8 @@
Client* client;
string url;
bool updateUsers;
+ size_t selCount;
+ bool statusDirty;
bool waitingForPW;
bool resort;
bool confirmClose;
@@ -200,8 +202,7 @@
size_t getUserCount() const;
pair<size_t, tstring> getStatusUsers() const;
- tstring getStatusShared() const;
- tstring getStatusAverageShared() const;
+ pair<tstring, tstring> getStatusShared() const;
void updateStatus();
void updateSecureStatus();