Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thread names #1120

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cafe/HW/Espresso/Debugger/GDBStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool GDBServer::Initialize()

void GDBServer::ThreadFunc()
{
SetThreadName("GDBServer::ThreadFunc");
SetThreadName("GDBServer");

while (!m_stopRequested)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ std::atomic_bool s_recompilerThreadStopSignal{false};

void PPCRecompiler_thread()
{
SetThreadName("PPCRecompiler_thread");
SetThreadName("PPCRecompiler");
while (true)
{
if(s_recompilerThreadStopSignal)
Expand Down
2 changes: 2 additions & 0 deletions src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <glslang/Public/ShaderLang.h>
#include <glslang/SPIRV/GlslangToSpv.h>
#include <util/helpers/helpers.h>

bool s_isLoadingShadersVk{ false };
class FileCache* s_spirvCache{nullptr};
Expand Down Expand Up @@ -155,6 +156,7 @@ class _ShaderVkThreadPool

void CompilerThreadFunc()
{
SetThreadName("vkShaderComp");
while (m_threadsActive.load(std::memory_order::relaxed))
{
s_compilationQueueCount.decrementWithWait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ bool VulkanPipelineStableCache::DeserializePipeline(MemStreamReader& memReader,

int VulkanPipelineStableCache::CompilerThread()
{
SetThreadName("plCacheCompiler");
while (m_numCompilationThreads != 0)
{
std::vector<uint8> pipelineData = m_compilationQueue.pop();
Expand All @@ -421,6 +422,7 @@ int VulkanPipelineStableCache::CompilerThread()

void VulkanPipelineStableCache::WorkerThread()
{
SetThreadName("plCacheWriter");
while (true)
{
CachedPipeline* job;
Expand Down
1 change: 1 addition & 0 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,7 @@ void VulkanRenderer::WaitCommandBufferFinished(uint64 commandBufferId)

void VulkanRenderer::PipelineCacheSaveThread(size_t cache_size)
{
SetThreadName("vkDriverPlCache");
const auto dir = ActiveSettings::GetCachePath("shaderCache/driver/vk");
if (!fs::exists(dir))
{
Expand Down
1 change: 1 addition & 0 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ std::queue<PipelineCompiler*> g_compilePipelineRequests;

void compilePipeline_thread(sint32 threadIndex)
{
SetThreadName("compilePl");
#ifdef _WIN32
// one thread runs at normal priority while the others run at lower priority
if(threadIndex != 0)
Expand Down
2 changes: 2 additions & 0 deletions src/Cafe/IOSU/ODM/iosu_odm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <util/helpers/helpers.h>
#include "iosu_odm.h"
#include "config/ActiveSettings.h"
#include "Common/FileStream.h"
Expand Down Expand Up @@ -79,6 +80,7 @@ namespace iosu

void ODMServiceThread()
{
SetThreadName("ODMService");
s_msgQueueId = IOS_CreateMessageQueue(_s_msgBuffer.GetPtr(), _s_msgBuffer.GetCount());
cemu_assert(!IOS_ResultIsError((IOS_ERROR)s_msgQueueId));
IOS_ERROR r = IOS_RegisterResourceManager(s_devicePath.c_str(), s_msgQueueId);
Expand Down
2 changes: 2 additions & 0 deletions src/Cafe/IOSU/PDM/iosu_pdm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <util/helpers/helpers.h>
#include "iosu_pdm.h"
#include "Cafe/CafeSystem.h"
#include "config/ActiveSettings.h"
Expand Down Expand Up @@ -387,6 +388,7 @@ namespace iosu

void TimeTrackingThread(uint64 titleId)
{
SetThreadName("PlayDiaryThread");
PlayStatsEntry* playStatsEntry = PlayStats_BeginNewTracking(titleId);

auto startTime = std::chrono::steady_clock::now();
Expand Down
1 change: 1 addition & 0 deletions src/Cafe/IOSU/nn/iosu_nn_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ namespace iosu

void IPCService::ServiceThread()
{
SetThreadName("IPCService");
m_msgQueueId = IOS_CreateMessageQueue(_m_msgBuffer.GetPtr(), _m_msgBuffer.GetCount());
cemu_assert(!IOS_ResultIsError((IOS_ERROR)m_msgQueueId));
IOS_ERROR r = IOS_RegisterResourceManager(m_devicePath.c_str(), m_msgQueueId);
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ namespace coreinit

void OSSchedulerCoreEmulationThread(void* _assignedCoreIndex)
{
SetThreadName(fmt::format("OSSchedulerThread[core={}]", (uintptr_t)_assignedCoreIndex).c_str());
SetThreadName(fmt::format("OSSched[core={}]", (uintptr_t)_assignedCoreIndex).c_str());
t_assignedCoreIndex = (sint32)(uintptr_t)_assignedCoreIndex;
#if defined(ARCH_X86_64)
_mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero
Expand Down
2 changes: 2 additions & 0 deletions src/Cafe/TitleList/SaveList.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "SaveList.h"
#include <charconv>
#include <util/helpers/helpers.h>

std::mutex sSLMutex;
fs::path sSLMLCPath;
Expand Down Expand Up @@ -44,6 +45,7 @@ void CafeSaveList::Refresh()

void CafeSaveList::RefreshThreadWorker()
{
SetThreadName("SaveListWorker");
// clear save list
for (auto& itSaveInfo : sSLList)
{
Expand Down
1 change: 1 addition & 0 deletions src/Cafe/TitleList/TitleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ void CafeTitleList::AddTitleFromPath(fs::path path)

bool CafeTitleList::RefreshWorkerThread()
{
SetThreadName("TitleListWorker");
while (sTLRefreshRequests.load())
{
sTLRefreshRequests.store(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Cemu/FileCache/FileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct _FileCacheAsyncWriter
private:
void FileCacheThread()
{
SetThreadName("fileCache_thread");
SetThreadName("fileCache");
while (true)
{
std::unique_lock lock(m_fileCacheMutex);
Expand Down
1 change: 1 addition & 0 deletions src/gui/components/wxGameList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ void wxGameList::RemoveCache(const std::list<fs::path>& cachePaths, const std::s

void wxGameList::AsyncWorkerThread()
{
SetThreadName("GameListWorker");
while (m_async_worker_active)
{
m_async_task_count.decrementWithWait();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/guiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void _wxLaunch()

void gui_create()
{
SetThreadName("MainThread");
SetThreadName("cemu");
#if BOOST_OS_WINDOWS
// on Windows wxWidgets there is a bug where wxDirDialog->ShowModal will deadlock in Windows internals somehow
// moving the UI thread off the main thread fixes this
Expand Down
2 changes: 1 addition & 1 deletion src/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ std::optional<glm::ivec2> InputManager::get_right_down_mouse_info(bool* is_pad)

void InputManager::update_thread()
{
SetThreadName("InputManager::update_thread");
SetThreadName("Input_update");
while (!m_update_thread_shutdown.load(std::memory_order::relaxed))
{
std::shared_lock lock(m_mutex);
Expand Down
4 changes: 2 additions & 2 deletions src/input/api/DSU/DSUControllerProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ MotionSample DSUControllerProvider::get_motion_sample(uint8_t index) const

void DSUControllerProvider::reader_thread()
{
SetThreadName("DSUControllerProvider::reader_thread");
SetThreadName("DSU-reader");
bool first_read = true;
while (m_running.load(std::memory_order_relaxed))
{
Expand Down Expand Up @@ -383,7 +383,7 @@ void DSUControllerProvider::reader_thread()

void DSUControllerProvider::writer_thread()
{
SetThreadName("DSUControllerProvider::writer_thread");
SetThreadName("DSU-writer");
while (m_running.load(std::memory_order_relaxed))
{
std::unique_lock lock(m_writer_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/input/api/SDL/SDLControllerProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ MotionSample SDLControllerProvider::motion_sample(int diid)

void SDLControllerProvider::event_thread()
{
SetThreadName("SDLControllerProvider::event_thread");
SetThreadName("SDL_events");
while (m_running.load(std::memory_order_relaxed))
{
SDL_Event event{};
Expand Down
4 changes: 2 additions & 2 deletions src/input/api/Wiimote/WiimoteControllerProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ WiimoteControllerProvider::WiimoteState WiimoteControllerProvider::get_state(siz

void WiimoteControllerProvider::reader_thread()
{
SetThreadName("WiimoteControllerProvider::reader_thread");
SetThreadName("Wiimote-reader");
std::chrono::steady_clock::time_point lastCheck = {};
while (m_running.load(std::memory_order_relaxed))
{
Expand Down Expand Up @@ -878,7 +878,7 @@ void WiimoteControllerProvider::set_motion_plus(size_t index, bool state)

void WiimoteControllerProvider::writer_thread()
{
SetThreadName("WiimoteControllerProvider::writer_thread");
SetThreadName("Wiimote-writer");
while (m_running.load(std::memory_order_relaxed))
{
std::unique_lock writer_lock(m_writer_mutex);
Expand Down
4 changes: 3 additions & 1 deletion src/util/helpers/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ void SetThreadName(const char* name)
#elif BOOST_OS_MACOS
pthread_setname_np(name);
#else
pthread_setname_np(pthread_self(), name);
if(std::strlen(name) > 15)
cemuLog_log(LogType::Force, "Truncating thread name {} because it was longer than 15 characters", name);
pthread_setname_np(pthread_self(), std::string{name}.substr(0,15).c_str());
#endif
}

Expand Down
Loading