Browse Source

Merge pull request #12180 from FranciscoPombal/fix_stats

Fix total connected peers count calculation
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
a9111b1357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/gui/statsdialog.cpp
  2. 19
      src/webui/api/synccontroller.cpp

20
src/gui/statsdialog.cpp

@ -90,21 +90,13 @@ void StatsDialog::update()
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) m_ui->labelWriteStarve->setText(QString("%1%").arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0))
const auto torrents = BitTorrent::Session::instance()->torrents(); ? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2)
const quint32 peers = std::accumulate(torrents.cbegin(), torrents.cend(), 0, [](const quint32 acc, const BitTorrent::TorrentHandle *torrent) : QLatin1String("0")));
{ m_ui->labelReadStarve->setText(QString("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0))
return (acc + torrent->peersCount()); ? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2)
}); : QLatin1String("0")));
m_ui->labelWriteStarve->setText(QString("%1%")
.arg(((ss.diskWriteQueue > 0) && (peers > 0))
? Utils::String::fromDouble((100. * ss.diskWriteQueue) / peers, 2)
: "0"));
m_ui->labelReadStarve->setText(QString("%1%")
.arg(((ss.diskReadQueue > 0) && (peers > 0))
? Utils::String::fromDouble((100. * ss.diskReadQueue) / peers, 2)
: "0"));
// Disk queues // Disk queues
m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength)); m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength));
m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime)); m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime));

19
src/webui/api/synccontroller.cpp

@ -110,7 +110,7 @@ namespace
void processList(QVariantList prevData, const QVariantList &data, QVariantList &syncData, QVariantList &removedItems); void processList(QVariantList prevData, const QVariantList &data, QVariantList &syncData, QVariantList &removedItems);
QVariantMap generateSyncData(int acceptedResponseId, const QVariantMap &data, QVariantMap &lastAcceptedData, QVariantMap &lastData); QVariantMap generateSyncData(int acceptedResponseId, const QVariantMap &data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
QVariantMap getTranserInfo() QVariantMap getTransferInfo()
{ {
QVariantMap map; QVariantMap map;
const auto *session = BitTorrent::Session::instance(); const auto *session = BitTorrent::Session::instance();
@ -136,15 +136,12 @@ namespace
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "0"; map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "0";
map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024; map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024;
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (sessionStatus.peersCount > 0))
const auto torrents = session->torrents(); ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue / sessionStatus.peersCount), 2)
const quint32 peers = std::accumulate(torrents.cbegin(), torrents.cend(), 0, [](const quint32 acc, const BitTorrent::TorrentHandle *torrent) : QLatin1String("0");
{ map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (sessionStatus.peersCount > 0))
return (acc + torrent->peersCount()); ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue / sessionStatus.peersCount), 2)
}); : QLatin1String("0");
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0";
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0";
map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength; map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength;
map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime; map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime;
@ -461,7 +458,7 @@ void SyncController::maindataAction()
tags << tag; tags << tag;
data["tags"] = tags; data["tags"] = tags;
QVariantMap serverState = getTranserInfo(); QVariantMap serverState = getTransferInfo();
serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled();

Loading…
Cancel
Save