SL-1370 Add more memory logging to mesh repository

meow-7.2.2
Andrey Kleshchev 2022-02-11 15:25:04 +02:00
parent de72b36aaa
commit 6f49893fb3
5 changed files with 72 additions and 23 deletions

View File

@ -1500,6 +1500,25 @@ LLSD LLMeshSkinInfo::asLLSD(bool include_joints, bool lock_scale_if_joint_positi
return ret;
}
U32 LLMeshSkinInfo::sizeBytes() const
{
U32 res = sizeof(LLUUID); // mMeshID
res += sizeof(std::vector<std::string>) + sizeof(std::string) * mJointNames.size();
for (U32 i = 0; i < mJointNames.size(); ++i)
{
res += mJointNames[i].size(); // actual size, not capacity
}
res += sizeof(std::vector<S32>) + sizeof(S32) * mJointNums.size();
res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * mInvBindMatrix.size();
res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * mAlternateBindMatrix.size();
res += 16 * sizeof(float); //mBindShapeMatrix
res += sizeof(float) + 3 * sizeof(bool);
return res;
}
LLModel::Decomposition::Decomposition(LLSD& data)
{
fromLLSD(data);
@ -1606,6 +1625,30 @@ void LLModel::Decomposition::fromLLSD(LLSD& decomp)
}
}
U32 LLModel::Decomposition::sizeBytes() const
{
U32 res = sizeof(LLUUID); // mMeshID
res += sizeof(LLModel::convex_hull_decomposition) + sizeof(std::vector<LLVector3>) * mHull.size();
for (U32 i = 0; i < mHull.size(); ++i)
{
res += mHull[i].size() * sizeof(LLVector3);
}
res += sizeof(LLModel::hull) + sizeof(LLVector3) * mBaseHull.size();
res += sizeof(std::vector<LLModel::PhysicsMesh>) + sizeof(std::vector<LLModel::PhysicsMesh>) * mMesh.size();
for (U32 i = 0; i < mMesh.size(); ++i)
{
res += mMesh[i].sizeBytes();
}
res += sizeof(std::vector<LLModel::PhysicsMesh>) * 2;
res += mBaseHullMesh.sizeBytes() + mPhysicsShapeMesh.sizeBytes();
return res;
}
bool LLModel::Decomposition::hasHullList() const
{
return !mHull.empty() ;

View File

@ -45,6 +45,7 @@ public:
LLMeshSkinInfo(LLSD& data);
void fromLLSD(LLSD& data);
LLSD asLLSD(bool include_joints, bool lock_scale_if_joint_position) const;
U32 sizeBytes() const;
LLUUID mMeshID;
std::vector<std::string> mJointNames;
@ -102,6 +103,14 @@ public:
{
return mPositions.empty();
}
U32 sizeBytes() const
{
U32 res = sizeof(std::vector<LLVector3>) * 2;
res += sizeof(LLVector3) * mPositions.size();
res += sizeof(LLVector3) * mNormals.size();
return res;
}
};
class Decomposition
@ -112,6 +121,7 @@ public:
void fromLLSD(LLSD& data);
LLSD asLLSD() const;
bool hasHullList() const;
U32 sizeBytes() const;
void merge(const Decomposition* rhs);

View File

@ -383,6 +383,9 @@ U32 LLMeshRepository::sLODPending = 0;
U32 LLMeshRepository::sCacheBytesRead = 0;
U32 LLMeshRepository::sCacheBytesWritten = 0;
U32 LLMeshRepository::sCacheBytesHeaders = 0;
U32 LLMeshRepository::sCacheBytesSkins = 0;
U32 LLMeshRepository::sCacheBytesDecomps = 0;
U32 LLMeshRepository::sCacheReads = 0;
U32 LLMeshRepository::sCacheWrites = 0;
U32 LLMeshRepository::sMaxLockHoldoffs = 0;
@ -1877,6 +1880,7 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes
LLMutexLock lock(mHeaderMutex);
mMeshHeaderSize[mesh_id] = header_size;
mMeshHeader[mesh_id] = header;
LLMeshRepository::sCacheBytesHeaders += header_size;
}
@ -3019,27 +3023,6 @@ S32 LLMeshRepository::getActualMeshLOD(LLSD& header, S32 lod)
return -1;
}
void LLMeshRepository::cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header)
{
mThread->mMeshHeader[data.mUUID] = header;
// we cache the mesh for default parameters
LLVolumeParams volume_params;
volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
volume_params.setSculptID(data.mUUID, LL_SCULPT_TYPE_MESH);
for (U32 i = 0; i < 4; i++)
{
if (data.mModel[i].notNull())
{
LLPointer<LLVolume> volume = new LLVolume(volume_params, LLVolumeLODGroup::getVolumeScaleFromDetail(i));
volume->copyVolumeFaces(data.mModel[i]);
volume->setMeshAssetLoaded(TRUE);
}
}
}
// Handle failed or successful requests for mesh assets.
//
// Support for 200 responses was added for several reasons. One,
@ -3957,6 +3940,8 @@ void LLMeshRepository::notifyLoadedMeshes()
void LLMeshRepository::notifySkinInfoReceived(LLMeshSkinInfo& info)
{
mSkinMap[info.mMeshID] = info;
// Alternative: We can get skin size from header
sCacheBytesSkins += info.sizeBytes();
skin_load_map::iterator iter = mLoadingSkins.find(info.mMeshID);
if (iter != mLoadingSkins.end())
@ -3980,10 +3965,14 @@ void LLMeshRepository::notifyDecompositionReceived(LLModel::Decomposition* decom
{ //just insert decomp into map
mDecompositionMap[decomp->mMeshID] = decomp;
mLoadingDecompositions.erase(decomp->mMeshID);
sCacheBytesDecomps += decomp->sizeBytes();
}
else
{ //merge decomp with existing entry
sCacheBytesDecomps -= iter->second->sizeBytes();
iter->second->merge(decomp);
sCacheBytesDecomps += iter->second->sizeBytes();
mLoadingDecompositions.erase(decomp->mMeshID);
delete decomp;
}

View File

@ -553,6 +553,9 @@ public:
static U32 sLODProcessing;
static U32 sCacheBytesRead;
static U32 sCacheBytesWritten;
static U32 sCacheBytesHeaders;
static U32 sCacheBytesSkins;
static U32 sCacheBytesDecomps;
static U32 sCacheReads;
static U32 sCacheWrites;
static U32 sMaxLockHoldoffs; // Maximum sequential locking failures
@ -642,8 +645,6 @@ public:
std::queue<LLUUID> mPendingPhysicsShapeRequests;
U32 mMeshThreadCount;
void cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header);
LLMeshRepoThread* mThread;
std::vector<LLMeshUploadThread*> mUploads;

View File

@ -778,6 +778,12 @@ public:
ypos += y_inc;
addText(xpos, ypos, llformat("%.3f/%.3f MB Mesh Cache Read/Write ", LLMeshRepository::sCacheBytesRead/(1024.f*1024.f), LLMeshRepository::sCacheBytesWritten/(1024.f*1024.f)));
ypos += y_inc;
addText(xpos, ypos, llformat("%.3f/%.3f MB Mesh Skins/Decompositions Memory", LLMeshRepository::sCacheBytesSkins / (1024.f*1024.f), LLMeshRepository::sCacheBytesDecomps / (1024.f*1024.f)));
ypos += y_inc;
addText(xpos, ypos, llformat("%.3f MB Mesh Headers Memory", LLMeshRepository::sCacheBytesHeaders / (1024.f*1024.f)));
ypos += y_inc;
}