diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-07-04 15:51:50 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-07-17 21:29:37 +0000 |
commit | c62bc2fe1388c580ccc83cbc28e6954027aeb002 (patch) | |
tree | f1e64e4d99e9c25eb73455c7de4bef883950cc70 /src/core/jobs/qthreadpooler.cpp | |
parent | 132d23ba1aa3a1df59ae4d49fd1842e9e50e5545 (diff) |
Job Traces: add support for Submission frames
We now have worker frames for jobs and submission frames for render command
submissions.
Since both can happen concurrently, slightly adjusted what needed to be.
Change-Id: I355bb6540090b4f569d38f4989dc9911dc381974
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/jobs/qthreadpooler.cpp')
-rw-r--r-- | src/core/jobs/qthreadpooler.cpp | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/src/core/jobs/qthreadpooler.cpp b/src/core/jobs/qthreadpooler.cpp index c49930f5a..35e2df2a1 100644 --- a/src/core/jobs/qthreadpooler.cpp +++ b/src/core/jobs/qthreadpooler.cpp @@ -174,6 +174,8 @@ int QThreadPooler::maxThreadCount() const QThreadStorage<QVector<JobRunStats> *> jobStatsCached; QVector<QVector<JobRunStats> *> localStorages; +QVector<JobRunStats> *submissionStorage = nullptr; + QMutex localStoragesMutex; // Called by the jobs @@ -188,14 +190,7 @@ void QThreadPooler::addJobLogStatsEntry(JobRunStats &stats) jobStatsCached.localData()->push_back(stats); } -// Called before jobs are executed (AspectThread) -void QThreadPooler::starNewFrameJobLogsStats() -{ - for (QVector<JobRunStats> *storage : qAsConst(localStorages)) - storage->clear(); -} - -// Called after jobs have been executed +// Called after jobs have been executed (AspectThread QAspectJobManager::enqueueJobs) void QThreadPooler::writeFrameJobLogStats() { static QScopedPointer<QFile> traceFile; @@ -206,25 +201,57 @@ void QThreadPooler::writeFrameJobLogStats() qCritical("Failed to open trace file"); } - FrameHeader header; - header.frameId = frameId; - header.jobCount = 0; + // Write Aspect + Job threads + { + FrameHeader header; + header.frameId = frameId; + header.jobCount = 0; - for (const QVector<JobRunStats> *storage : qAsConst(localStorages)) - header.jobCount += storage->size(); - - traceFile->write(reinterpret_cast<char *>(&header), sizeof(FrameHeader)); + for (const QVector<JobRunStats> *storage : qAsConst(localStorages)) + header.jobCount += storage->size(); + traceFile->write(reinterpret_cast<char *>(&header), sizeof(FrameHeader)); + for (QVector<JobRunStats> *storage : qAsConst(localStorages)) { + for (const JobRunStats &stat : *storage) + traceFile->write(reinterpret_cast<const char *>(&stat), sizeof(JobRunStats)); + storage->clear(); + } + } - for (const QVector<JobRunStats> *storage : qAsConst(localStorages)) { - for (const JobRunStats &stat : *storage) { - traceFile->write(reinterpret_cast<const char *>(&stat), sizeof(JobRunStats)); + // Write submission thread + { + QMutexLocker lock(&localStoragesMutex); + const int submissionJobSize = submissionStorage != nullptr ? submissionStorage->size() : 0; + if (submissionJobSize > 0) { + FrameHeader header; + header.frameId = frameId; + header.jobCount = submissionJobSize; + header.frameType = FrameHeader::Submission; + + traceFile->write(reinterpret_cast<char *>(&header), sizeof(FrameHeader)); + + for (const JobRunStats &stat : *submissionStorage) + traceFile->write(reinterpret_cast<const char *>(&stat), sizeof(JobRunStats)); + submissionStorage->clear(); } } + traceFile->flush(); ++frameId; } + +// Called from Submission thread +void QThreadPooler::addSubmissionLogStatsEntry(JobRunStats &stats) +{ + QMutexLocker lock(&localStoragesMutex); + if (!jobStatsCached.hasLocalData()) { + submissionStorage = new QVector<JobRunStats>; + jobStatsCached.setLocalData(submissionStorage); + } + submissionStorage->push_back(stats); +} + #endif } // namespace Qt3DCore |