summaryrefslogtreecommitdiffstats
path: root/src/core/jobs/qthreadpooler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Update commercial license headers"v5.15.3-lts-lgplTarja Sundqvist2021-03-231-21/+21
| | | | | | | | | | | This reverts commit 03e5f60e585701608c1181365faee484d7a1f14c. Revert of commercial license headers is required for Qt 5.15.3 opensource release. Task-number: QTBUG-91108 Change-Id: I359e89ed77b1b2750607617d138ebb6c316f0296 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* Update commercial license headersTarja Sundqvist2021-02-021-21/+21
| | | | | | | | | | | | | | | | Updated header.COMM to the files in tqtc-qt3d. Examples, documentation files or tests are not updated. The commercial license header may contain some additional lines so that its line count equals with the earlier license header. Reason for this is that some autotests use hard coded line numbers and a change in the line count causes failures in tests. Task-number: QTQAINFRA-4155 Change-Id: I139c8ad72c042b0900239decc36cfed4bc1c4951 Reviewed-by: Jukka Jokiniva <jukka.jokiniva@qt.io>
* Centralize the maxThreadCount informationPaul Lemire2020-05-271-10/+16
| | | | | | | | | | | | Add a static function on QThreadPooler which returns the ideal thread count (capped by QT3D_MAX_THREAD_COUNT) if set. Call that function from all places that need that information. Avoids code duplication and potentially reading the env value every frame. Change-Id: I699691af33ed0a65aa557ed48aabb9de8929dcc2 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit 1097607f112e79ddb4fc08d012db95faa193c4ea)
* Fix memory leaksMike Krus2020-03-041-5/+19
| | | | | | | | | | | Some jobs get skipped because they don't have anything to do. However, since the runnable does not get submitted to the pool, it would leak (along with the job it points to). Also fixed a couple of compile warnings. Change-Id: I7a25649f2f760c0593862328c0ab905da98c982a Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Add flag to jobs to indicate if they need to run or notMike Krus2020-02-141-13/+37
| | | | | | | | | | | | | | | | | | | Once aspect jobs are inserted in the queue, they will always run, but some of them don't actually have anything to do at every frame. Ideally, when building a graph of jobs, you would include only jobs that are required. However this makes building the graph more complicated. This introduces a method on the private job pimple which indicated if the job actually has something to do or not. When the scheduler is ready to run a job, it will call that method. If there's nothing to do, then the job will be skipped and the dependent jobs (if any) run instead. Change-Id: Iaa8d3d064f03d8c0bab407879a9acea292a06784 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Make tracing a runtime optionMike Krus2019-12-131-117/+0
| | | | | | | | | | | - Moved most of the code QSystemInformationService (private class for now) - Tracing can be enabled by setting QT3D_TRACE_ENABLED or calling QSystemInformationService::setTraceEnabled(bool) - Introduced QTaskLogger class to easy logging (RAII) Change-Id: I2a3e08e4371fcee3e9ef3cf575725f13f57d1a94 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Make QThreadPooler use the global thread poolPaul Lemire2019-12-021-5/+8
| | | | | | | This should ensure we don't have too many idling threads Change-Id: Ia533fc07140a4944a1149aca1565b0d8ae3cda22 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Fix deprecation warnings related to QBasicAtomicIntegerFriedemann Kleint2019-09-191-1/+1
| | | | | | | | | Use loadRelaxed(), storeRelaxed(), fixing warnings like: renderers/opengl/renderer/renderer.cpp:451:22: warning: ‘void QBasicAtomicInteger<T>::store(T) [with T = int]’ is deprecated: Use storeRelaxed [-Wdeprecated-declarations] qt3d/src/render/renderers/opengl/renderer/renderer_p.h:188:61: warning: ‘T QBasicAtomicInteger<T>::load() const [with T = int]’ is deprecated: Use loadRelaxed [-Wdeprecated-declarations] Change-Id: Ica946808969e7f311c98e30d1a61c1b4fa22f66a Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix QThreadPoolerPaul Lemire2019-08-071-2/+8
| | | | | | | Handle Manual Drive mode / Scene3D changes jobs stats Change-Id: Iadd7dd64580ce88145b264df5adcfc8bcb36b66a Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Fix compilation with -qt3d-profile-jobs on AndroidPaul Lemire2018-10-051-0/+5
| | | | | Change-Id: Id6dc461bbc61712f59484898c54a85d07fd8fc22 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Merge branch '5.9' into 5.10Sean Harmer2017-09-121-14/+21
|\ | | | | | | Change-Id: Id6a3d4ec579a2f2a2e559c22a2293d0e184f0bdf
| * Improve dependency look-upChristian Strømme2017-09-061-14/+21
| | | | | | | | | | | | | | | | | | Simplify the dependency look-up by moving the dependers directly into the dependee runnable, each task is then responsible for updating their dependers and queue them up when they are free to be run. Change-Id: I96295d47cecd507a864965e1fb65f2ff9af68111 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge branch '5.9' into devSean Harmer2017-08-191-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/render/backend/renderer.cpp src/render/backend/renderview.cpp src/render/graphicshelpers/graphicscontext_p.h src/render/graphicshelpers/graphicshelperes2_p.h src/render/graphicshelpers/graphicshelpergl2_p.h src/render/graphicshelpers/graphicshelpergl3_2_p.h src/render/graphicshelpers/graphicshelpergl3_3_p.h src/render/graphicshelpers/graphicshelpergl4_p.h src/render/graphicshelpers/graphicshelperinterface_p.h src/render/jobs/pickboundingvolumejob.cpp tests/auto/animation/clipanimator/tst_clipanimator.cpp tests/auto/auto.pro tests/manual/manual.pro Also disabled the QQmlMetaType codepaths following commit 49a11e882059ee1729f776722e085dd21d378c36 in qtdeclarative. The QQmlMetaType codepaths will be re-enabled once a qt5.git integration has succeeded. Change-Id: Ia654d75425e6d406c472d19864383612208cad2b
| * Fix compilation on linux with -qt3d-profile-jobsPaul Lemire2017-08-031-0/+1
| | | | | | | | | | Change-Id: Iebecab6fa362bb6bda4ee720cb0259214ced52a4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Properly use QT_CONFIG for Qt3D profiling optionsPaul Lemire2017-08-031-5/+5
| | | | | | | | | | | | Change-Id: Id3bb7bb657f3d48c6c4cd3d5e86c43ad64dca791 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Make ThreadPool thread count configurable with QT3D_MAX_THREAD_COUNTPaul Lemire2017-08-021-0/+7
|/ | | | | Change-Id: I50671d11b2c6ae950abe013ad371c1f1f74516b0 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Merge branch '5.8' into 5.9Sean Harmer2017-04-021-8/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/core/jobs/qthreadpooler.cpp src/core/nodes/qcomponent.cpp src/core/qpostman.cpp src/core/qscene_p.h src/core/services/qservicelocator_p.h src/input/frontend/qinputaspect.cpp src/plugins/sceneparsers/assimp/assimpimporter.cpp src/plugins/sceneparsers/assimp/assimpimporter.h src/plugins/sceneparsers/gltf/gltfimporter.h src/plugins/sceneparsers/gltf/gltfio.cpp src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp src/quick3d/imports/render/qt3dquick3drenderplugin.cpp src/quick3d/quick3dextras/qt3dquickwindow.cpp Change-Id: I3566708c6f74a34959e7bb64b64e93647ca3f699
| * Fixes includes to comply with coding conventions for Src/CoreRobert Brock2017-03-311-5/+6
| | | | | | | | | | | | | | | | Reordering the header includes to comply with Qt coding conventions Task-number: QTBUG-56185 Change-Id: I3943678c183c4ef46d403e0fff878c3cad964dfa Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | QThreadPooler: improve job traces namePaul Lemire2017-03-281-2/+10
| | | | | | | | | | | | | | | | And save the trace in the Download folder on Android, otherwise it's impossible to retrieve the trace on non rooted devices. Change-Id: Icc6f11429738350df26081003d9bc51233521668 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Initialize member in QThreadPoolerSean Harmer2017-02-121-4/+5
|/ | | | | | Change-Id: I7c59c48fbdeac30d0f2f3caefb6b71e19550e9f8 Coverity-Id: 154600 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Job Traces: add support for Submission framesPaul Lemire2016-07-171-18/+45
| | | | | | | | | 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>
* QThreadPooler: append date to jobs trace filePaul Lemire2016-06-271-2/+2
| | | | | | | | Makes it easier to keep separate trace files as otherwise the trace file was overwritten. Change-Id: Ib980e13f36e7ad32f02d4ea9b79b720096f565b3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QThreadPooler: eradicate remaining Q_FOREACHMarc Mutz2016-05-141-12/+7
| | | | | | | Also expanded the obfuscating typedefs. Change-Id: Idfe7c1e7c04dd4ff896fc7f73967bb8c00ce7b9c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Q_NULLPTR -> nullptrSean Harmer2016-05-011-2/+2
| | | | | | Task-number: QTBUG-52736 Change-Id: I58f9cbcdf018e7b672d33dd865067485412b79fe Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* QThreadPooler: aggregate mutex by valueMarc Mutz2016-04-301-8/+6
| | | | | | | | There's no reason to incur a heap allocation for something as simple as a mutex. Change-Id: I9489b2348c142e028009b757d8f922fea43e168b Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QThreadPooler: QVector::clear() no longer sheds capacityMarc Mutz2016-04-281-2/+0
| | | | | | | | ... (since qtbase/a7885c9756d423042bd0670d82d78d8dffe9be54) so there's no need to restore capacity manually. Change-Id: Ie8004a496860d7ed67977365956d95f9d82f6732 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QThreadPooler: minimize critical sectionMarc Mutz2016-04-281-1/+1
| | | | | | | | | | The localStorageMutex only needs to be held when appending to localStorages here, because the heap allocation is a purely local act and setting the object on QThreadStorage is thead-safe. Change-Id: I01f6f12a22e19ec0d53d5e039779c6917dbbda05 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add more job run statsPaul Lemire2016-03-211-1/+0
| | | | | | | | - store submission time - store instance of the renderview Change-Id: Ifccb63b9adc93fa16c9e950b4c0300d8b3414b88 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Qt3D job run statsPaul Lemire2016-03-041-0/+79
| | | | | | | | | | | Add a way to write to a trace.qt3d file stats about the frame jobs Then use the qt3dprofiler tool to visualize the trace file This is enabled by defining QT3D_JOBS_RUN_STATS at compile time Change-Id: I4d2faaf5189cd91ecc88b7ca0ca3e3e1f2f60498 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-261-4/+0
|\ | | | | | | | | | | | | | | | | Conflicts: src/doc/src/qt3dcollision-module.qdoc src/render/frontend/qcamera.cpp src/render/frontend/qcameralens.cpp Change-Id: I8a0ae250a6b8e065a1ef3c817968ebb7ef23b20d
| * Doc: Exclude private header files from the documentation buildTopi Reinio2016-01-251-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | In the documentation configuration, exclude all '_p.h' files from the documentation build. This prevents QDoc from generating documentation for private classes, and also allows removal of documentation that explicitly set the private classes \internal. Change-Id: I8fcf5c99a2a0b75e9ee5dcd928fa4a2b4b8cf34f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Unify license header usageAntti Kokko2016-01-261-12/+15
|/ | | | | | | Update old header.LGPL3 to header.LGPL Change-Id: I8eac0cd6bbc276a56df487249cc459c0d4fab165 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* QThreadPooler: few improvementsPaul Lemire2015-12-061-24/+13
| | | | | | Change-Id: Ib312bacc9703bfde65d2d95e953f57e55635aebc Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Mika Salmela <mika.salmela@theqtcompany.com>
* Doc: Documentation clean upVenugopal Shivashankar2015-11-061-1/+1
| | | | | | | | | | - Changed 'Qt3D' references to 'Qt 3D'. - Fixed incorrect \inqmlmodule instances. - Fixed broken \printuntil instances in the example docs. - Updated the namespace qualifier for a few class references. Change-Id: I250afe6843b10ed520f9ce5d7465203cc5c212c1 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* QThreadPooler: use a private ThreadPoolPaul Lemire2015-10-241-4/+4
| | | | | | | | as anyone could modify the expiry timeout on the global instance of the QThreadPool Change-Id: I5114273f799b95f8237f580d8e18133769052ff6 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Prevent QThreadPool from recycling threadsSean Harmer2015-10-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thanks to discussions with Paul Lemire and David Faure we noticed that ThreadPooler does not change QThreadPool's default behavior of recycling threads after 30 seconds of inactivity. For Qt3D this is disasterous. This resulted in fairly reliable crashes when stepping through Qt3D applications in a debugger or totally unpredictably when running normally. In the normal run case it is unpredicable as which jobs get scheduled to which thread is somewhat random. So if you're unlucky you will see random crashes. If you are very lucky QThreadPool and the system scheduler will cycle through the threads in the pool when assigning jobs to threads, stopping the threads from being recycled. When a thread in the pool does get recycled, the TLS for that thread gets destroyed and when QThreadPool recreates the thread we now potentially have a QThread with the same address but without any valid TLS contents. Of course we rely heavily upon the contents of the TLS by way of the frame allocator. Therefore, the thread recycling of QThreadPool was breaking our assumption of the frame allocators living for the duration of the application. With this commit it is now possible to have extended debugging sessions of Qt3D applications and it should no longer crash at random (at least not because of this issue). Change-Id: Id9f4f5d023fac1cda5cda436b62fb24ace40da84 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Mika Salmela <mika.salmela@theqtcompany.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
* Move Qt3DCore into Qt3DCore namespaceSean Harmer2015-10-131-3/+3
| | | | | | | Update other aspects, tests and examples accordingly. Change-Id: Ib1bcf0bdf4f5aec4422dc0c80bfc32b27fb1a317 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Expose the max thread count from the poolerLaszlo Agocs2015-07-311-0/+5
| | | | | | | | | | | | Assuming that the pooler allows up to idealThreadCount() threads is only true when the default settings of QThreadPool are in use. Once the limit gets reduced via setMaxThreadCount(), we get a deadlock. So expose the max number of threads (like with ThreadWeaver) from QThreadPooler and use that value instaed. Change-Id: I1ec0789da5f52a5b333b24f4b3b37dd487c69841 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Add mutex to QThreadPooler destructorMika Salmela2015-05-271-0/+4
| | | | | | | | Added mutex to QThreadPooler destructor to wait that mutex is not destroyed while locked. This seems to be important for autotests. Change-Id: I5423344ecd2c24e896adaf5b9b52309200ed8801 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* ThreadPooler future reservation under mutexMika Salmela2015-05-261-0/+8
| | | | | | | Added mutex for QFuture reservation on QThreadPooler Change-Id: I6fc399c2518180d78a7ed387a90330af02b1b8a5 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
* Add checks for double task executionMika Salmela2015-04-271-4/+8
| | | | | | | | | | On ThreadPooler done tasks are also removed from the dependency pair list. Also added reserved flag for tasks. These prevent tasks getting into execution more than once. Change-Id: Ia9e5377c883ad08079a9af32c4a2a294db425eb2 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Implement ThreadPooler using QThreadPoolMika Salmela2015-04-241-172/+58
| | | | | | | Re-implemented ThreadPooler to use QRunnable and QThreadPool. Change-Id: I3da0182489b648dcb6b671c57b4474c183bddeec Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
* Doc: Fix multiple C++ documentation issuesTopi Reinio2015-04-141-0/+4
| | | | | | | | | | | | | | | | | | | - Remove multiple \namespace commands for namespace Qt3D. QDoc in 5.5 is now able to collate namespace members from multiple modules. - Mark 'Q...Private' classes and functions taking private arguments as \internal - Use correct \qtvariable for Qt 3D Core and Render - Add src/plugins directory to Qt 3D Core documentation build to correctly generate Assimp-related documentation. - Ensure documentation for C++ properties is visible by using the \property command instead of documenting the setter/getter functions. - Add export and logging macros to qdoc ignore directives - Remove unnecessary use of \fn command - Language and styling fixes Change-Id: I2481fa30ad2f6869b85c038c20ff1730b8522d46 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Fix for ThreadPooler flushMika Salmela2015-02-261-0/+3
| | | | | | | | | Increment running thread counter before removing task from the queue. This prevents the idle test to pass if queue is empty and job runner hasn't yet increased the counter. Change-Id: I01992ef6e9b437d2ce3d9f62e6025b3122e19fa8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* ThreadPooler to replace ThreadWeaverMika Salmela2015-02-191-0/+260
Initial version of ThreadPooler to substitute 3rd party ThreadWeaver. Qt3D will be released under LGPLv3 and commercial licensing terms, therefore we can't share code with free licenses. Change-Id: Ic0956b40e4960002205ee32c19a053813339791c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>