Make coroutines stack size configurable
This allows rapid debugging of the coroutine memory issues. It moves the default stack size to 256 * 4096 = 2^20, which will utilize full pages on all architectures.
This commit is contained in:
parent
a6b36adb32
commit
fbc19ab893
|
@ -39,6 +39,18 @@
|
||||||
*/
|
*/
|
||||||
static const wxChar AdvancedConfigMask[] = wxT( "KICAD_ADVANCED_CONFIG" );
|
static const wxChar AdvancedConfigMask[] = wxT( "KICAD_ADVANCED_CONFIG" );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limits and default settings for the coroutine stack size allowed.
|
||||||
|
* Warning! Setting the stack size below the default may lead to unexplained crashes
|
||||||
|
* This configuration setting is intended for developers only.
|
||||||
|
*/
|
||||||
|
namespace AC_STACK
|
||||||
|
{
|
||||||
|
static constexpr int min_stack = 32 * 4096;
|
||||||
|
static constexpr int default_stack = 256 * 4096;
|
||||||
|
static constexpr int max_stack = 4096 * 4096;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of known keys for advanced configuration options.
|
* List of known keys for advanced configuration options.
|
||||||
*
|
*
|
||||||
|
@ -72,6 +84,12 @@ static const wxChar RealtimeConnectivity[] = wxT( "RealtimeConnectivity" );
|
||||||
*/
|
*/
|
||||||
static const wxChar AllowLegacyCanvasInGtk3[] = wxT( "AllowLegacyCanvasInGtk3" );
|
static const wxChar AllowLegacyCanvasInGtk3[] = wxT( "AllowLegacyCanvasInGtk3" );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the coroutine stack size in bytes. This should be allocated in multiples of
|
||||||
|
* the system page size (n*4096 is generally safe)
|
||||||
|
*/
|
||||||
|
static const wxChar CoroutineStackSize[] = wxT( "CoroutineStackSize" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw zones in pcbnew with the stroked outline.
|
* Draw zones in pcbnew with the stroked outline.
|
||||||
*/
|
*/
|
||||||
|
@ -158,6 +176,7 @@ ADVANCED_CFG::ADVANCED_CFG()
|
||||||
m_allowLegacyCanvasInGtk3 = false;
|
m_allowLegacyCanvasInGtk3 = false;
|
||||||
m_realTimeConnectivity = true;
|
m_realTimeConnectivity = true;
|
||||||
m_forceThickOutlinesInZones = true;
|
m_forceThickOutlinesInZones = true;
|
||||||
|
m_coroutineStackSize = AC_STACK::default_stack;
|
||||||
|
|
||||||
loadFromConfigFile();
|
loadFromConfigFile();
|
||||||
}
|
}
|
||||||
|
@ -200,6 +219,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
||||||
configParams.push_back(
|
configParams.push_back(
|
||||||
new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, &m_realTimeConnectivity, false ) );
|
new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, &m_realTimeConnectivity, false ) );
|
||||||
|
|
||||||
|
configParams.push_back(
|
||||||
|
new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize, &m_coroutineStackSize,
|
||||||
|
AC_STACK::default_stack, AC_STACK::min_stack, AC_STACK::max_stack ) );
|
||||||
|
|
||||||
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ForceThickZones,
|
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ForceThickZones,
|
||||||
&m_forceThickOutlinesInZones, true ) );
|
&m_forceThickOutlinesInZones, true ) );
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,11 @@ public:
|
||||||
*/
|
*/
|
||||||
bool m_forceThickOutlinesInZones;
|
bool m_forceThickOutlinesInZones;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the stack size for coroutines
|
||||||
|
*/
|
||||||
|
int m_coroutineStackSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to determine if legacy canvas is allowed (according to platform
|
* Helper to determine if legacy canvas is allowed (according to platform
|
||||||
* and config)
|
* and config)
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#ifdef KICAD_USE_VALGRIND
|
#ifdef KICAD_USE_VALGRIND
|
||||||
#include <valgrind/valgrind.h>
|
#include <valgrind/valgrind.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <advanced_config.h>
|
||||||
#include <system/libcontext.h>
|
#include <system/libcontext.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ public:
|
||||||
,valgrind_stack( 0 )
|
,valgrind_stack( 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
m_stacksize = ADVANCED_CFG::GetCfg().m_coroutineStackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
~COROUTINE()
|
~COROUTINE()
|
||||||
|
@ -304,7 +305,7 @@ private:
|
||||||
|
|
||||||
assert( m_stack == nullptr );
|
assert( m_stack == nullptr );
|
||||||
|
|
||||||
size_t stackSize = c_defaultStackSize;
|
size_t stackSize = m_stacksize;
|
||||||
void* sp = nullptr;
|
void* sp = nullptr;
|
||||||
|
|
||||||
#ifndef LIBCONTEXT_HAS_OWN_STACK
|
#ifndef LIBCONTEXT_HAS_OWN_STACK
|
||||||
|
@ -380,11 +381,11 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int c_defaultStackSize = 2000000; // fixme: make configurable
|
|
||||||
|
|
||||||
///< coroutine stack
|
///< coroutine stack
|
||||||
std::unique_ptr<char[]> m_stack;
|
std::unique_ptr<char[]> m_stack;
|
||||||
|
|
||||||
|
int m_stacksize;
|
||||||
|
|
||||||
std::function<ReturnType( ArgType )> m_func;
|
std::function<ReturnType( ArgType )> m_func;
|
||||||
|
|
||||||
bool m_running;
|
bool m_running;
|
||||||
|
|
Loading…
Reference in New Issue