Show stats for writing and reading navmesh db queue jobs

crashfix_debugdraw
elsid 2 years ago
parent bedfbfd594
commit e9be8b5efe
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -111,6 +111,11 @@ namespace DetourNavigator
static std::atomic_size_t nextJobId {1};
return nextJobId.fetch_add(1);
}
bool isWritingDbJob(const Job& job)
{
return job.mGeneratedNavMeshData != nullptr;
}
}
std::ostream& operator<<(std::ostream& stream, JobStatus value)
@ -328,7 +333,8 @@ namespace DetourNavigator
if (stats.mDb.has_value())
{
out.setAttribute(frameNumber, "NavMesh DbJobs", static_cast<double>(stats.mDb->mJobs));
out.setAttribute(frameNumber, "NavMesh DbJobs Write", static_cast<double>(stats.mDb->mJobs.mWritingJobs));
out.setAttribute(frameNumber, "NavMesh DbJobs Read", static_cast<double>(stats.mDb->mJobs.mReadingJobs));
if (stats.mDb->mGetTileCount > 0)
out.setAttribute(frameNumber, "NavMesh DbCacheHitRate", static_cast<double>(stats.mDbGetTileHits)
@ -690,6 +696,10 @@ namespace DetourNavigator
{
const std::lock_guard lock(mMutex);
insertPrioritizedDbJob(job, mJobs);
if (isWritingDbJob(*job))
++mWritingJobs;
else
++mReadingJobs;
mHasJob.notify_all();
}
@ -701,6 +711,10 @@ namespace DetourNavigator
return std::nullopt;
const JobIt job = mJobs.front();
mJobs.pop_front();
if (isWritingDbJob(*job))
--mWritingJobs;
else
--mReadingJobs;
return job;
}
@ -719,10 +733,10 @@ namespace DetourNavigator
mHasJob.notify_all();
}
std::size_t DbJobQueue::size() const
DbJobQueue::Stats DbJobQueue::getStats() const
{
const std::lock_guard lock(mMutex);
return mJobs.size();
return Stats {.mWritingJobs = mWritingJobs, .mReadingJobs = mReadingJobs};
}
DbWorker::DbWorker(AsyncNavMeshUpdater& updater, std::unique_ptr<NavMeshDb>&& db,
@ -751,10 +765,7 @@ namespace DetourNavigator
DbWorker::Stats DbWorker::getStats() const
{
Stats result;
result.mJobs = mQueue.size();
result.mGetTileCount = mGetTileCount.load(std::memory_order_relaxed);
return result;
return Stats {.mJobs = mQueue.getStats(), .mGetTileCount = mGetTileCount.load(std::memory_order_relaxed)};
}
void DbWorker::stop()
@ -809,7 +820,7 @@ namespace DetourNavigator
}
};
if (job->mGeneratedNavMeshData != nullptr)
if (isWritingDbJob(*job))
{
process([&] (JobIt job) { processWritingJob(job); });
mUpdater.removeJob(job);

@ -80,6 +80,12 @@ namespace DetourNavigator
class DbJobQueue
{
public:
struct Stats
{
std::size_t mWritingJobs;
std::size_t mReadingJobs;
};
void push(JobIt job);
std::optional<JobIt> pop();
@ -88,13 +94,15 @@ namespace DetourNavigator
void stop();
std::size_t size() const;
Stats getStats() const;
private:
mutable std::mutex mMutex;
std::condition_variable mHasJob;
std::deque<JobIt> mJobs;
bool mShouldStop = false;
std::size_t mWritingJobs = 0;
std::size_t mReadingJobs = 0;
};
class AsyncNavMeshUpdater;
@ -104,8 +112,8 @@ namespace DetourNavigator
public:
struct Stats
{
std::size_t mJobs = 0;
std::size_t mGetTileCount = 0;
DbJobQueue::Stats mJobs;
std::size_t mGetTileCount;
};
DbWorker(AsyncNavMeshUpdater& updater, std::unique_ptr<NavMeshDb>&& db,

@ -439,7 +439,8 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase *viewer)
"NavMesh Waiting",
"NavMesh Pushed",
"NavMesh Processing",
"NavMesh DbJobs",
"NavMesh DbJobs Write",
"NavMesh DbJobs Read",
"NavMesh DbCacheHitRate",
"NavMesh CacheSize",
"NavMesh UsedTiles",

Loading…
Cancel
Save