7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 13:19:34 +00:00

Add Advanced Config parameter for thread count

Allows us to limit the threading state manually without recompiling
This commit is contained in:
Seth Hillbrand 2025-01-03 14:00:07 -08:00
parent 361f61a023
commit 2e0f688b97
3 changed files with 19 additions and 2 deletions

View File

@ -121,9 +121,9 @@ static const wxChar EnableExtensionSnaps[] = wxT( "EnableExtensionSnaps" );
static const wxChar ExtensionSnapTimeoutMs[] = wxT( "ExtensionSnapTimeoutMs" );
static const wxChar ExtensionSnapActivateOnHover[] = wxT( "ExtensionSnapActivateOnHover" );
static const wxChar EnableSnapAnchorsDebug[] = wxT( "EnableSnapAnchorsDebug" );
static const wxChar EnableJobset[] = wxT( "EnableJobset" );
static const wxChar MinParallelAngle[] = wxT( "MinParallelAngle" );
static const wxChar HoleWallPaintingMultiplier[] = wxT( "HoleWallPaintingMultiplier" );
static const wxChar MaximumThreads[] = wxT( "MaximumThreads" );
} // namespace KEYS
@ -296,6 +296,8 @@ ADVANCED_CFG::ADVANCED_CFG()
m_MinParallelAngle = 0.001;
m_HoleWallPaintingMultiplier = 1.5;
m_MaximumThreads = 0;
loadFromConfigFile();
}
@ -565,6 +567,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_HoleWallPaintingMultiplier, m_HoleWallPaintingMultiplier,
0.1, 100.0 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::MaximumThreads,
&m_MaximumThreads, m_MaximumThreads,
0, 500 ) );
// Special case for trace mask setting...we just grab them and set them immediately
// Because we even use wxLogTrace inside of advanced config
wxString traceMasks;

View File

@ -707,6 +707,15 @@ public:
*/
double m_HoleWallPaintingMultiplier;
/**
* Default value for the maximum number of threads to use for parallel processing.
* Setting this value to 0 or less will mean that we use the number of cores available
*
* Setting name: "MaximumThreads"
* Default value: 0
*/
int m_MaximumThreads;
///@}
private:

View File

@ -21,6 +21,7 @@
#define KICAD_SINGLETON_H
#include <bs_thread_pool.hpp>
#include <advanced_config.h>
class KICAD_SINGLETON
{
@ -38,7 +39,8 @@ public:
void Init()
{
m_ThreadPool = new BS::thread_pool();
int num_threads = std::max( 0, ADVANCED_CFG::GetCfg().m_MaximumThreads );
m_ThreadPool = new BS::thread_pool( num_threads );
}
BS::thread_pool* m_ThreadPool;