mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 19:34:02 +02:00
add some basic send tracking
This commit is contained in:
parent
38182bfd9d
commit
08ba535c38
7 changed files with 72 additions and 0 deletions
|
@ -266,3 +266,49 @@ void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectio
|
|||
tree->setWantEditLogging(wantEditLogging);
|
||||
tree->setWantTerseEditLogging(wantTerseEditLogging);
|
||||
}
|
||||
|
||||
void EntityServer::trackSend(const QUuid& dataID, const QUuid& viewerNode) {
|
||||
QWriteLocker locker(&_viewerSendingStatsLock);
|
||||
_viewerSendingStats[viewerNode] = usecTimestampNow();
|
||||
}
|
||||
|
||||
|
||||
QString EntityServer::serverSubclassStats() {
|
||||
QLocale locale(QLocale::English);
|
||||
QString statsString;
|
||||
|
||||
// display memory usage stats
|
||||
statsString += "<b>Entity Server Memory Statistics</b>\r\n";
|
||||
statsString += QString().sprintf("EntityTreeElement size... %ld bytes\r\n", sizeof(EntityTreeElement));
|
||||
statsString += QString().sprintf(" EntityItem size... %ld bytes\r\n", sizeof(EntityItem));
|
||||
statsString += "\r\n\r\n";
|
||||
|
||||
statsString += "<b>Entity Server Sending to Viewer Statistics</b>\r\n";
|
||||
statsString += "----- Viewer Node ID ----------------- ---------- Last Sent To ----------\r\n";
|
||||
|
||||
int viewers = 0;
|
||||
const int COLUMN_WIDTH = 24;
|
||||
|
||||
{
|
||||
QReadLocker locker(&_viewerSendingStatsLock);
|
||||
quint64 now = usecTimestampNow();
|
||||
|
||||
for (auto key : _viewerSendingStats.keys()) {
|
||||
quint64 lastSentAt = _viewerSendingStats[key];
|
||||
quint64 elapsed = now - lastSentAt;
|
||||
double msecsAgo = (double)(elapsed / USECS_PER_MSEC);
|
||||
statsString += key.toString();
|
||||
statsString += " ";
|
||||
statsString += QString("%1 msecs ago\r\n")
|
||||
.arg(locale.toString((double)msecsAgo).rightJustified(COLUMN_WIDTH, ' '));
|
||||
|
||||
viewers++;
|
||||
}
|
||||
}
|
||||
if (viewers < 1) {
|
||||
statsString += " no viewers... \r\n";
|
||||
}
|
||||
statsString += "\r\n\r\n";
|
||||
|
||||
return statsString;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ public:
|
|||
|
||||
virtual void entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode) override;
|
||||
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject) override;
|
||||
virtual QString serverSubclassStats();
|
||||
|
||||
virtual void trackSend(const QUuid& dataID, const QUuid& viewerNode);
|
||||
|
||||
public slots:
|
||||
void pruneDeletedEntities();
|
||||
|
@ -57,6 +60,9 @@ private slots:
|
|||
private:
|
||||
EntitySimulation* _entitySimulation;
|
||||
QTimer* _pruneDeletedEntitiesTimer = nullptr;
|
||||
|
||||
QReadWriteLock _viewerSendingStatsLock;
|
||||
QMap<QUuid,quint64> _viewerSendingStats;
|
||||
};
|
||||
|
||||
#endif // hifi_EntityServer_h
|
||||
|
|
|
@ -467,6 +467,12 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
|||
isFullScene, &nodeData->stats, _myServer->getJurisdiction(),
|
||||
&nodeData->extraEncodeData);
|
||||
|
||||
// Our trackSend() function is implemented by the server subclass, and will be called back
|
||||
// during the encodeTreeBitstream() as new entities/data elements are sent
|
||||
params.trackSend = [this](const QUuid& id) {
|
||||
_myServer->trackSend(id, _nodeUUID);
|
||||
};
|
||||
|
||||
// TODO: should this include the lock time or not? This stat is sent down to the client,
|
||||
// it seems like it may be a good idea to include the lock time as part of the encode time
|
||||
// are reported to client. Since you can encode without the lock
|
||||
|
|
|
@ -821,6 +821,11 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
.arg(locale.toString((uint)checkSum).rightJustified(16, ' '));
|
||||
|
||||
statsString += "\r\n\r\n";
|
||||
|
||||
statsString += serverSubclassStats();
|
||||
|
||||
statsString += "\r\n\r\n";
|
||||
|
||||
statsString += "</pre>\r\n";
|
||||
statsString += "</doc></html>";
|
||||
|
||||
|
|
|
@ -79,6 +79,8 @@ public:
|
|||
virtual void beforeRun() { }
|
||||
virtual bool hasSpecialPacketsToSend(const SharedNodePointer& node) { return false; }
|
||||
virtual int sendSpecialPackets(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent) { return 0; }
|
||||
virtual QString serverSubclassStats() { return QString(); }
|
||||
virtual void trackSend(const QUuid& dataID, const QUuid& viewerNode) { }
|
||||
|
||||
static float SKIP_TIME; // use this for trackXXXTime() calls for non-times
|
||||
|
||||
|
|
|
@ -311,6 +311,11 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
entityTreeElementExtraEncodeData->entities.insert(getEntityItemID(), propertiesDidntFit);
|
||||
}
|
||||
|
||||
// if any part of our entity was sent, call trackSend
|
||||
if (appendState != OctreeElement::NONE) {
|
||||
params.trackSend(getID());
|
||||
}
|
||||
|
||||
return appendState;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,8 @@ public:
|
|||
case OCCLUDED: return QString("OCCLUDED"); break;
|
||||
}
|
||||
}
|
||||
|
||||
std::function<void(const QUuid&)> trackSend { [](const QUuid&){} };
|
||||
};
|
||||
|
||||
class ReadElementBufferToTreeArgs {
|
||||
|
|
Loading…
Reference in a new issue