forked from mirror/openmw-tes3mp
Update the resource cache every second instead of every frame
A dry run takes about ~1.5ms. Even though it's all done in the worker thread, the locks used can stall loading operations that are about to happen in other threads, and just in general this CPU load is unnecessary.
This commit is contained in:
parent
b4a6b6387b
commit
0be811c519
2 changed files with 9 additions and 2 deletions
|
@ -179,6 +179,7 @@ namespace MWWorld
|
|||
, mMinCacheSize(0)
|
||||
, mMaxCacheSize(0)
|
||||
, mPreloadInstances(true)
|
||||
, mLastResourceCacheUpdate(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -252,8 +253,12 @@ namespace MWWorld
|
|||
++it;
|
||||
}
|
||||
|
||||
// the resource cache is cleared from the worker thread so that we're not holding up the main thread with delete operations
|
||||
mWorkQueue->addWorkItem(new UpdateCacheItem(mResourceSystem, mTerrain, timestamp), true);
|
||||
if (timestamp - mLastResourceCacheUpdate > 1.0)
|
||||
{
|
||||
// the resource cache is cleared from the worker thread so that we're not holding up the main thread with delete operations
|
||||
mWorkQueue->addWorkItem(new UpdateCacheItem(mResourceSystem, mTerrain, timestamp), true);
|
||||
mLastResourceCacheUpdate = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
void CellPreloader::setExpiryDelay(double expiryDelay)
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace MWWorld
|
|||
unsigned int mMaxCacheSize;
|
||||
bool mPreloadInstances;
|
||||
|
||||
double mLastResourceCacheUpdate;
|
||||
|
||||
struct PreloadEntry
|
||||
{
|
||||
PreloadEntry(double timestamp, osg::ref_ptr<SceneUtil::WorkItem> workItem)
|
||||
|
|
Loading…
Reference in a new issue