Add API to query max MMCSS threads on Windows
By default Windows limits the number of MMCSS threads to 32. This can cause problems on modern systems with >= 32 cores, when Ardour uses many process and I/O threads. So far this is just a first step (query API)
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <glibmm.h>
|
||||
|
||||
#include "pbd/cpus.h"
|
||||
#include "pbd/history_owner.h"
|
||||
#include "pbd/stateful_diff_command.h"
|
||||
#include "pbd/openuri.h"
|
||||
@@ -609,6 +610,9 @@ LuaBindings::common (lua_State* L)
|
||||
.addConst ("UseGroup", PBD::Controllable::GroupControlDisposition(PBD::Controllable::UseGroup))
|
||||
.endNamespace ()
|
||||
|
||||
.addFunction ("hardware_concurrency", hardware_concurrency)
|
||||
.addFunction ("max_mmcss_threads_per_process", max_mmcss_threads_per_process)
|
||||
|
||||
.endNamespace (); // PBD
|
||||
|
||||
luabridge::getGlobalNamespace (L)
|
||||
|
||||
@@ -39,6 +39,27 @@
|
||||
#include <ardourext/pthread.h> // Gets us 'PTW32_VERSION'
|
||||
#endif
|
||||
|
||||
int32_t
|
||||
max_mmcss_threads_per_process ()
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
DWORD dwType = REG_DWORD;
|
||||
DWORD dwSize = 4;
|
||||
int32_t rv = 32;
|
||||
HKEY hKey;
|
||||
if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile", 0, KEY_READ, &hKey)) {
|
||||
if (ERROR_SUCCESS == RegQueryValueExA (hKey, "MaxThreadsPerProcess", 0, &dwType, (LPBYTE)&rv, &dwSize)) {
|
||||
if (dwType == REG_DWORD && dwSize == 4) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 32;
|
||||
#else
|
||||
return INT32_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t
|
||||
hardware_concurrency()
|
||||
{
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
#include "pbd/libpbd_visibility.h"
|
||||
|
||||
LIBPBD_API extern uint32_t hardware_concurrency ();
|
||||
|
||||
LIBPBD_API extern int32_t max_mmcss_threads_per_process ();
|
||||
|
||||
Reference in New Issue
Block a user