Commit graph

76 commits

Author SHA1 Message Date
Henrik Rydgård
6b0903f566 Add facility to run tasks on dedicated threads using the ThreadManager interface.
Useful for things that should be run ASAP even if the threadpool is full,
at a small extra cost. (Not recommended for very small tasks).

Considering using this to resolve the deadlocks in #16802.
2023-01-31 11:07:40 +01:00
Unknown W. Brackets
3a6fa9b4ba ThreadManager: Don't allow reordering of queue.
Allowing a priority item is faster, but can cause confusion when you
expect things to run in the same sequence they're enqueued.
2023-01-14 16:35:01 -08:00
Henrik Rydgård
7672556e5c Better pipeline descriptions in shader viewer (shorter in overview, longer after click) 2023-01-09 11:22:35 +01:00
Henrik Rydgård
ab6fafb6eb Invert dependency to avoid compile issues 2023-01-05 08:38:53 +01:00
Henrik Rydgård
7e374c9324 Address feedback, more fixes 2023-01-05 08:38:53 +01:00
Henrik Rydgård
b56eef487c Strict mode checking - no way to forget detaching now.
And if we forget to attach, boom. Hopefully I caught all of them.
2023-01-05 08:38:52 +01:00
Henrik Rydgård
916404f0e4 Try to get a bit better at detaching threads that have used JNI from the VM. 2023-01-05 08:38:49 +01:00
Unknown W. Brackets
a800938604 Common: Fix worker thread names. 2022-12-10 10:40:32 -08:00
Johan Mattsson
2b1d57257a
Fix comparison 2022-12-03 15:28:22 +01:00
Henrik Rydgård
25547b5fe2 Make Mailbox handle null values. Fixes hang. 2022-11-08 00:21:08 +01:00
Henrik Rydgård
3393d47e92 Remove ill-formed asserts 2022-09-23 23:14:36 +02:00
Henrik Rydgård
e828df9f25 Split each renderpass/framebuffer into multiple "compatibility classes" (RenderPassType). 2022-09-08 00:32:03 +02:00
Henrik Rydgård
76bd2395bf Promise: Add SpawnEmpty (couldn't come up with a better name), fix bug with multiple waiters 2022-09-03 15:21:08 +02:00
Henrik Rydgård
c06cf8efaa Switch Vulkan pipelines to use promises for synchronization
Slightly more expensive I guess but shouldn't be much of a bottleneck.
2022-09-03 15:21:08 +02:00
Henrik Rydgård
ebe2d1b30f More buildfixing 2022-09-03 15:21:07 +02:00
Henrik Rydgård
210233ede0 Buildfix 2022-09-03 15:21:07 +02:00
Henrik Rydgård
e701037267 Buildfix 2022-09-03 15:21:07 +02:00
Henrik Rydgård
8775837c11 Work towards finding the leak 2022-09-03 15:21:07 +02:00
Henrik Rydgård
ec0586ba50 Use promises to hold shader modules, for later asyncification 2022-09-03 15:21:07 +02:00
Henrik Rydgård
8d8a553f5b Fix typo and optimize locking pattern in Event, make it the same as LimitedWaitable. 2022-04-15 18:30:21 +02:00
Unknown W. Brackets
81ace52f53 ThreadManager: Improve waitable destruction. 2022-04-09 09:27:26 -07:00
Henrik Rydgård
adfce57d9e Fix race condition in LimitedWaitable between Notify and Wait 2022-04-08 12:29:30 +02:00
Henrik Rydgård
bde54ccdc0 Fix misuses of cond.wait (should return true when you want to stop waiting!) 2022-04-08 12:28:45 +02:00
Henrik Rydgård
5b20ace502 OK, this does crash 2022-04-08 12:04:34 +02:00
Henrik Rydgård
b04e5925d2 Add a scheduling stress test to TestThreadManager.cpp.
Was hoping to find the cause of the issue I looked at in #15431
2022-04-08 11:41:50 +02:00
Unknown W. Brackets
ffbd9bbe98 Global: Fix some int/size_t conversion warnings. 2022-03-13 12:03:48 -07:00
Unknown W. Brackets
2479d52202 Global: Reduce includes of common headers.
In many places, string, map, or Common.h were included but not needed.
2022-01-30 16:35:33 -08:00
Unknown W. Brackets
55c11425e4 softgpu: Use persistent bin task state.
It's constant, so it's better to avoid the copying and allocation.  A
small win, but removes new from the profile.
2022-01-20 16:58:43 -08:00
Unknown W. Brackets
dffc333120 softgpu: Avoid thread ordering hazard.
Must run the primitives in the right order.  No shortcutting allowed.
2022-01-13 23:03:42 -08:00
Unknown W. Brackets
7c7340e338 ThreadManager: Check for exchange failure.
Even if expected stays null, since it's weak assume it can fail.
2021-12-07 18:24:01 -08:00
Unknown W. Brackets
f9a7ad3e3d ThreadManager: Use separate pool for IO blocking.
This prevents starving the compute pool (which may be used very regularly
parallel loops or other tasks) if the IO operations are slow.
2021-12-05 21:01:49 -08:00
Unknown W. Brackets
8b5173350f ThreadManager: Make TaskType a property of a Task. 2021-12-05 21:01:49 -08:00
Unknown W. Brackets
12b790bb81 ThreadManager: Protect against teardown hang/leak.
Make sure we lock during canceled checks/updates, and also try to free
tasks queued on threads that didn't end up running.
2021-11-27 08:57:19 -08:00
Unknown W. Brackets
de9a4dcede ThreadManager: Lock notify on global queue add.
Otherwise, it's possible the chosen thread might not wake up, and then it
may wait for another task to be enqueued - potentially causing a hang.
2021-11-27 08:57:19 -08:00
Unknown W. Brackets
d15af6e9d9 ThreadManager: Use atomic task optimistically.
This makes EnqueueTaskOnThread take priority as well.
Gives about 1% improvement in softgpu, reducing overhead a bit.
2021-11-27 08:07:12 -08:00
Henrik Rydgård
4f85b8b2ef Threading: Remove a level of indirection from Promise and Mailbox.
Makes using small copyable or POD objects in these more efficient, and if you want
to you can just put a pointer or smart pointer in there, which will
effectively do the same thing as the old setup.
2021-11-20 22:40:10 +01:00
Unknown W. Brackets
e21f2b8fcf
Common: UWP buildfix.
Just use SetThreadDescription() directly, assuming new enough Windows.
2021-11-13 09:40:07 -08:00
Henrik Rydgård
9f1c9b9963 Buildfix 2021-11-13 18:12:09 +01:00
Henrik Rydgård
6e1455fd55 Use the "new" API SetThreadDescription to set thread names on Windows.
Mainly useful in debugging and profiling tools. Using the new function helps
modern debugging/profiling tools like Superluminal which don't support the
old exception method.

(Is there any old tool left that might be a reason we'd want to do both?)
2021-11-13 18:02:36 +01:00
Unknown W. Brackets
3ac669f80b Core: Fix some minor gcc warnings. 2021-09-13 08:13:14 -07:00
Henrik Rydgård
0d9d360b07 ThreadManager cleanups 2021-09-08 23:24:00 +02:00
Jan Beich
ae39923223 Thread: set names on BSDs after 062566b67c 2021-08-10 16:44:44 +00:00
Jan Beich
5b7557acd4 Thread: unbreak on BSDs after 50d9d7ea6f
Common/Thread/ThreadUtil.cpp:149:2: error: use of undeclared identifier 'pthread_threadid_np'
        pthread_threadid_np(NULL, &tid);
        ^
2021-08-10 16:44:41 +00:00
Stuart Kenny
96454fcbb6 Revert removal of Teardown call
As per review recommendation.
2021-07-08 15:39:51 +01:00
Stuart Kenny
02a24cdb7d Fix black screen on multiple libretro content loads.
Moves ThreadPool teardown to retro_unload_game. Gives ThreadPool threads some breathing room to terminate before game load starts spamming it with tasks.
2021-07-08 08:34:48 +01:00
Henrik Rydgård
15a2373f04 Implement thread debug id with the syscall instead of gettid().
See #14545
2021-06-21 01:27:17 +02:00
Henrik Rydgård
692a54ea74 An attempt at cleaning up the checks in ThreadUtil 2021-06-19 14:54:36 +02:00
Henrik Rydgård
c92775d26b Try a slightly rougher fix for libretro builds
(our builds work, but not their CI)
2021-06-14 22:44:27 +02:00
Henrik Rydgård
727b84ce5e Possible fix for reported problem with gettid() in libretro 2021-06-14 18:07:24 +02:00
Unknown W. Brackets
8ae3f5eb41 Android: Fix logical CPU count.
Otherwise bad things happen.
2021-06-13 12:47:11 -07:00