[+] RuntimeConfig.hpp

[+] RuntimeAliases.hpp
This commit is contained in:
Reece Wilson 2023-12-01 02:41:58 +00:00
parent eb1ec8b763
commit 741c7228d3
3 changed files with 395 additions and 374 deletions

View File

@ -78,386 +78,14 @@
#include "Utility/RateLimiter.hpp"
#include "Memory/_ByteBuffer.hpp"
namespace AuAsync = Aurora::Async;
namespace AuBuild = Aurora::Build;
namespace AuCompression = Aurora::Compression;
namespace AuConsole = Aurora::Console;
namespace AuCmdLine = Aurora::CmdLine;
namespace AuCrypto = Aurora::Crypto;
namespace AuData = Aurora::Data;
namespace AuDebug = Aurora::Debug;
namespace AuThreading = Aurora::Threading;
namespace AuThreadPrimitives = Aurora::Threading::Primitives;
namespace AuThreads = Aurora::Threading::Threads;
namespace AuHwInfo = Aurora::HWInfo;
namespace AuSwInfo = Aurora::SWInfo;
namespace AuIO = Aurora::IO;
namespace AuIOFS = Aurora::IO::FS;
namespace AuIONet = Aurora::IO::Net;
namespace AuIOIPC = Aurora::IO::IPC;
namespace AuIOLoop = Aurora::IO::Loop;
// Legacy shorthands; wont deprecate
namespace AuIPC = Aurora::IO::IPC;
namespace AuLoop = Aurora::IO::Loop;
namespace AuNet = Aurora::IO::Net;
namespace AuFS = Aurora::IO::FS;
namespace AuRng = Aurora::RNG;
namespace AuRNG = Aurora::RNG;
namespace AuLocale = Aurora::Locale;
namespace AuParse = Aurora::Parse;
namespace AuProcess = Aurora::Process;
namespace AuProcesses = Aurora::Processes;
namespace AuTelemetry = Aurora::Telemetry;
namespace AuTime = Aurora::Time;
namespace AuTypes = Aurora::Types;
namespace AuLog = Aurora::Logging;
namespace AuMemory = Aurora::Memory;
namespace AuHashing = Aurora::Hashing;
namespace AuExit = Aurora::Exit;
using AuWorkerId_t = AuAsync::WorkerId_t;
using AuWorkerPId_t = AuAsync::WorkerPId_t;
using AuByteBuffer = AuMemory::ByteBuffer;
using AuMemoryViewRead = AuMemory::MemoryViewRead;
using AuMemoryViewWrite = AuMemory::MemoryViewWrite;
using AuMemoryViewStreamRead = AuMemory::MemoryViewStreamRead;
using AuMemoryViewStreamWrite = AuMemory::MemoryViewStreamWrite;
#if defined(AURORA_RUNTIME_BAD_PLATFORM_FORCE_FUTEX_MUTEX_SEMAPHORE_IN_CLIENT)
using AuMutex = AuThreading::Waitables::FutexWaitable;
using AuSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
#else
using AuMutex = AuThreadPrimitives::Mutex;
using AuSemaphore = AuThreadPrimitives::Semaphore;
#endif
using AuRenterableMutex = AuThreadPrimitives::CriticalSection;
using AuCriticalSection = AuThreadPrimitives::CriticalSection;
using AuRWRenterableLock = AuThreadPrimitives::RWRenterableLock;
using AuRWLock = AuThreadPrimitives::RWLock;
using AuCond = AuThreadPrimitives::ConditionVariable;
using AuConditionVariable = AuThreadPrimitives::ConditionVariable;
using AuCondition = AuThreadPrimitives::ConditionVariable;
using AuCondMutex = AuThreadPrimitives::ConditionMutex;
using AuSpinLock = AuThreadPrimitives::SpinLock;
using AuCondEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuFlexibleConditionVariable = AuThreadPrimitives::FlexibleConditionVariable;
using AuConditionEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuBinarySemaphore = AuThreadPrimitives::Event;
using AuEvent = AuThreadPrimitives::Event;
using AuFutexMutex = AuThreading::Waitables::FutexWaitable;
using AuFutexSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
using AuFutexCond = AuThreading::Waitables::FutexCondWaitable;
using AuFutexCondition = AuThreading::Waitables::FutexCondWaitable;
using AuFutexBarrier = AuThreading::Waitables::FutexBarrier;
using AuBarrier = AuThreading::Waitables::FutexBarrier;
using AuInitOnce = AuThreading::InitOnce;
using AuInitOnceSmall = __audetail::InitOnceABI;
template<typename T, bool bIsStatic = false>
using AuTLSVariable = AuThreads::TLSVariable<T, bIsStatic>;
using AuIOHandle = AuIO::IOHandle;
using AuSharedIOHandle = AuSPtr<AuIO::IOHandle>;
#include "RuntimeAliases.hpp"
#include "Aurora/Async/AuFutures.hpp"
static bool AuIsThreadRunning()
{
return !AuThreads::GetThread()->Exiting();
}
static inline void AuDebugBreak()
{
AuDebug::DebugBreak();
}
#include "RuntimeConfig.hpp"
namespace Aurora
{
// The following configuration structures are a mess you probably wont need to think about for a while.
// Let's assume it's safe to move on for now, alright?
struct LocalLogInfo
{
bool bEnableLogging { true };
AuLog::DirectoryLogger defaultFileLogger
{
/* uMaxLogsOrZeroBeforeCompress */ 16, /* uMaxLogsOrZeroBeforeDelete */ 0,
/* uMaxCumulativeFileSizeInMiBOrZeroBeforeCompress*/ 0, /* uMaxCumulativeFileSizeInMiBOrZeroBeforeDelete */ 128 * 1024 * 1024,
0, 0
};
#if defined(AU_CFG_ID_SHIP)
bool bWriteLogsToUserDir { true }; // use user directory
#else
bool bWriteLogsToUserDir { false }; // use cwd
#endif
};
struct TelemetryConfigDoc
{
bool enabled { false };
};
struct TelemetryConfig
{
bool readModNameJsonConfig {};
TelemetryConfigDoc defaultConfig;
};
struct ConsoleConfig
{
/// Enables Aurora::Console::xxxStd functions; defer to enableStdXX for default logger behaviour
bool enableStdPassthrough {false};
/// Enables standard, debug, and GUI consoles
bool enableConsole {true};
/// Attempt to force a terminal emulator host under graphical subsystems
bool forceConsoleWindow {};
/// Attempt to force a GUI console under command line targets
bool forceToolKitWindow {};
/// In conjunction with enableStdPassthrough, Aurora::Console::ReadStd reads a binary stream
/// In conjunction with !enableStdPassthrough, enables stdin cmd processing, otherwise disables stdin input
bool enableStdIn {true};
/// In conjunction with enableStdPassthrough, enables Aurora::Console::WriteStd to write binary, otherwise enables the console logger
/// In conjunction with !enableStdPassthrough, enables stdout logging
bool enableStdOut {true};
/// Use WxWidgets when possible
bool enableWxWidgets {true};
/// Delegate stdout writes to loops -> recommended for servers
bool asyncWrite {true};
/// Async debug log
bool asyncVSLog {false};
/// Should stdout print the full date or a mere HH MM SS prefix?
bool bStdOutShortTime { false };
///
bool bStdOutUseLocalTime { true };
#if 1
/// FIO config
LocalLogInfo fio;
#endif
AuString titleBrand = "Aurora SDK Sample";
AuString supportPublic {"https://git.reece.sx/AuroraSupport/AuroraRuntime/issues"};
AuString supportInternal {"https://jira.reece.sx"};
bool consoleTTYHasPerAppHistory {true};
};
struct LoggerConfig
{
/// FIO config
LocalLogInfo fileConfiguration;
/// Socket config
// tbd
};
struct CryptoConfig
{
/// Defer to the rationales in the implementation
/// Update 2023: world war 3 hasnt happened yet
bool allowChineseCerts {false};
/// Defer to the rationales in the implementation
/// Update 2023: spoilers it had nothing to do with the 2022 russian trolling directly, but who didn't see it coming?
/// i dont care about politics; its just useful to divide the glow by factions.
bool allowRussianCerts {true};
};
struct AsyncConfig
{
bool bStartSchedularOnStartup { true }; // turn this off to make your application lighter-weight; turn this on for higher performance (+expensive) scheduling
bool bEnableLegacyTicks { false }; // turn this on to enable an async apps singleton threadpool to SysPump on worker id zero. Alternatively, use SetMainThreadForSysPumpScheduling once you have a thread pool and worker id.
AuUInt32 threadPoolDefaultStackSize { };
AuUInt32 dwSchedulerRateLimitMS { 2 }; //
AuUInt32 dwLegacyMainThreadSystemTickMS { 25 }; // nowadays this is primarily used to dispatch main-thread posted (AuConsole) commands
};
struct FIOConfig
{
AuOptional<AuString> optDefaultBrand = "Aurora SDK Sample";
bool bForceOverlappedUtilsToDelegatedThreadPool { false };
bool bIsIntranetTrusted {};
AuUInt32 uOverlappedUtilsThreadPoolSize { 2 }; // note: this does not relate to the overlapped aio apis
}; // these threads are only spawned as a fallback for AuFS::Overlapped*** apis
struct DebugConfig
{
/**
* @brief Precache/initialize symbols for printable stack traces under binaries not intended for shipping to consumers
*
* @warning true will result in artificially high commit charge under certain monitoring applications as application databases are
* precached into memory. these maps shouldn't be duplicated across processes (if the kernel plays nice). regardless,
* end users shouldn't see the hit. in the best case scenario, this serves as a quality of life upgrade for stage/debug
* binaries that want real time stack traces with file locations cached. noting that this isn't optional for stage win32
* builds with live exception traces with line info. in the future, debug tools should be able to parse telemetry dumps, though.
*/
bool bNonshipPrecachesSymbols { true };
/**
* @brief Activates the internal AddVectoredExceptionHandler handler. Might conflict with DRM and other debugging utilities
*/
bool bEnableWin32RootExceptionHandler { true };
/**
* @brief
*/
bool bEnableInjectedExceptionHandler { true };
/**
* @brief Raises a SysPanic in place of returning null over all allocators. This includes C++ containers which *should* be configured to use our overloaded allocators (compile ./Source/Alloc.cpp & link in with your application/library).
* If you're one of those people who don't like the idea of raising out of memory exceptions, and therefore compile without exceptions, this is an alternative this allows for exceptions to remain enabled for truly exceptional behaviour
* IE: we're fucked. Lets see if we can restart the root tick, at the risk of unaccounted for behaviour, because crashing over a STL parse exception or something stupid in that ballpark would be a really terrible **[end]user**-experience.
*/
bool bIsMemoryErrorFatal { false };
/**
* @brief
*/
bool bIsExceptionThrowFatal { false };
bool bSaveAllExceptionsAsMinidumpInBg { false };
bool bRaiseDebuggerToAllExceptionsInStageAndDbg { true };
bool bPrintExceptionStackTracesOut { true };
bool bIsApplicationClientSoftwareOnJitteryMemorySystem { false }; // enable me to enable padding from system out of memory conditions.
// the catch: usually this memory is reserved for exit callbacks, internal low memory conditions, error reporting, and the like.
//
// generally you should not exploit this without ** acknowledging this thread-local condition via AuDebug::[Add/Dec]MemoryCrunch. ** ( << tl;dr: recommended way of accessing this memory)
//
// setting this flag enables debug buffer memory to be used at any point during any threads execution - the moment mimalloc runs
// out of pre-reserved and system mappable memory. i wouldn't use this for anything except monolithic client/user-facing applications
// that are likely to run on low resource systems (low spec or heavy app), with untested/uncaught C++ allocations splattered everywhere.
// this could be VERY useful to end users who are running into `bIsMemoryErrorFatal` crashes.
AuUInt32 uDebugMemoryReserveSize { 3 * 1024 * 1024 }; /* nowdays: a single v8 isolate is low sub-tens MB of memory, executable file sizes are low mbs, image sizes are much larger. forget small low-footprint vms
of flex and bison yesteryear. 3MB given our heavyish standard footprint already is probably fine. how much memory do Java heap+JIT engines sink just to boot again?
this'll allow us to high tens of KBs of malicous strings, overhead for doing telemetry/(structured ???)logging, overhead to stack traces, module cache, etc.
i'm sure it'll also be enough to give back to the user, if need be.
@warning: 0 = 3 * 1024 * 1024
*/
bool bWin32VerifyTrustFailMissingAPI { true }; // just to not be annoying in the future
};
struct ThreadingConfig
{
// WARN: these values are not final
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar instruction before yielding into the kernel
AuUInt16 uSpinLoopPowerA { 128 }; // Nudgable spinloop power. This is our local userland niceness factor
// This is comparable to Win32's SetCriticalSectionSpinCount applied across every single AuThreadPrimitives try-lock and lock.
// Adjust this value to compensate for longer critical sections when context switching isn't preferrable.
AuUInt64 bEnableAggressiveScheduling : 1 { false };
AuUInt64 bEnableAgrSchedulingRatelimit : 1 { true };
AuUInt64 bPreferNt51XpMutexesOver8 : 1 { false };
AuUInt64 bPreferNt51XpCondvarsOver8 : 1 { false };
AuUInt64 bPreferNtCondvarModernWinSpin : 1 { false };
AuUInt64 bPreferNtCondvarOlderWinSpin : 1 { true };
AuUInt64 bPreferNtSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferNtMutexSpinTryLock : 1 { true };
AuUInt64 bPreferNtCondMutexSpinTryLock : 1 { false };
AuUInt64 bPreferLinuxSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true };
#if 0
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false };
#else
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { !AuBuild::kIsNtDerived /*everybody else requires us to hit the kernel. */ };
#endif
AuUInt64 bPreferWaitOnAddressAlwaysSpin : 1 { false }; // ..., if emulated! if double-spinning under higher level locks, disable me.
AuUInt64 bPreferWaitOnAddressAlwaysSpinNative : 1 { !AuBuild::kIsNtDerived }; // ..., if not emulated! noting that most kernels and user-schedulers will spin for you
AuUInt64 bPreferRWLockReadLockSpin : 1 { true };
AuUInt64 bUWPNanosecondEmulationCheckFirst : 1 { false };
AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 };
AuUInt64 bForceEnableAdaptiveSpin : 1 { false }; // ||
AuUInt64 bPreferEnableAdaptiveSpin : 1 { true }; // .
AuUInt64 bPreferLinuxAdaptiveSpin : 1 { true }; // (&&)
AuUInt64 bPreferOldWin32AdaptiveSpin : 1 { false }; // (&&)
AuUInt64 bPreferNewWin32AdaptiveSpin : 1 { true }; // (&&)
AuUInt64 uAdaptiveSpinCUCnt0 : 4 { 0 } ;
AuUInt64 uAdaptiveSpinCUCnt4 : 4 { 2 };
AuUInt64 uAdaptiveSpinCUCnt8 : 4 { 2 };
AuUInt64 uAdaptiveSpinCUCnt16 : 4 { 4 };
AuUInt64 bPreferFutexRWLock : 1 { true };
AuUInt64 bWinXpThrough7BlazeOptimizerPower : 12 { 300 }; // dont worry about it. we dont care about old portables. lets try to make older win32 targets tweak the scheduling in our favor a bit.
AuUInt64 bPreferLinuxPrimitivesFutexNoSpin : 1 { false };
AuUInt64 bPreferUnixPrimitivesNoSpin : 1 { false };
AuUInt64 bAlwaysRWLockWriteBiasOnReadLock : 1 { false };
AuUInt64 bEnableRWLockWriteBiasOnReadLock : 1 { true };
AuUInt64 bPreferFutexEvent : 1 { true };
};
struct DummyConfig
{
};
struct LinuxConfig
{
bool bFIODisableBatching { false };
bool bIOLinuxHasProcIpcPerms { false };
AuUInt8 uSignalTerminate { 27 };
AuUInt8 uSignalGAIOWorkerThreadDone { 28 };
};
struct ProcessConfig
{
bool bAlwaysPreloadEntireClassPath { false };
bool bForcePreload { false };
bool bEnablePreload { true };
};
struct IOConfig
{
AuUInt32 uProtocolStackDefaultBufferSize { 64 * 1024 };
};
struct Win32Config
{
bool bProcessCheckWinLdrForModNameFirst { true };
};
struct RuntimeStartInfo
{
ConsoleConfig console;
AuAlignTo<512, CryptoConfig> crypto;
AuAlignTo<512, TelemetryConfig> telemetry;
AuAlignTo<32, AsyncConfig> async;
AuAlignTo<32, FIOConfig> fio;
AuAlignTo<64, DebugConfig> debug;
AuAlignTo<32, ThreadingConfig> threadingConfig;
AuAlignTo<32, LinuxConfig> linuxConfig;
AuAlignTo<32, Win32Config> win32Config;
AuAlignTo<32, ProcessConfig> processConfig;
AuAlignTo<32, IOConfig> ioConfig;
AuAlignTo<32, DummyConfig> padding;
};
/**
* @brief Initializes Aurora Runtime for the first and only time
* @return

View File

@ -0,0 +1,108 @@
/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: RuntimeAliases.hpp
Date: 2023-1-12
Author: Reece
***/
#pragma once
namespace AuAsync = Aurora::Async;
namespace AuBuild = Aurora::Build;
namespace AuCompression = Aurora::Compression;
namespace AuConsole = Aurora::Console;
namespace AuCmdLine = Aurora::CmdLine;
namespace AuCrypto = Aurora::Crypto;
namespace AuData = Aurora::Data;
namespace AuDebug = Aurora::Debug;
namespace AuThreading = Aurora::Threading;
namespace AuThreadPrimitives = Aurora::Threading::Primitives;
namespace AuThreads = Aurora::Threading::Threads;
namespace AuHwInfo = Aurora::HWInfo;
namespace AuSwInfo = Aurora::SWInfo;
namespace AuIO = Aurora::IO;
namespace AuIOFS = Aurora::IO::FS;
namespace AuIONet = Aurora::IO::Net;
namespace AuIOIPC = Aurora::IO::IPC;
namespace AuIOLoop = Aurora::IO::Loop;
// Legacy shorthands; wont deprecate
namespace AuIPC = Aurora::IO::IPC;
namespace AuLoop = Aurora::IO::Loop;
namespace AuNet = Aurora::IO::Net;
namespace AuFS = Aurora::IO::FS;
namespace AuRng = Aurora::RNG;
namespace AuRNG = Aurora::RNG;
namespace AuLocale = Aurora::Locale;
namespace AuParse = Aurora::Parse;
namespace AuProcess = Aurora::Process;
namespace AuProcesses = Aurora::Processes;
namespace AuTelemetry = Aurora::Telemetry;
namespace AuTime = Aurora::Time;
namespace AuTypes = Aurora::Types;
namespace AuLog = Aurora::Logging;
namespace AuMemory = Aurora::Memory;
namespace AuHashing = Aurora::Hashing;
namespace AuExit = Aurora::Exit;
using AuWorkerId_t = AuAsync::WorkerId_t;
using AuWorkerPId_t = AuAsync::WorkerPId_t;
using AuByteBuffer = AuMemory::ByteBuffer;
using AuMemoryViewRead = AuMemory::MemoryViewRead;
using AuMemoryViewWrite = AuMemory::MemoryViewWrite;
using AuMemoryViewStreamRead = AuMemory::MemoryViewStreamRead;
using AuMemoryViewStreamWrite = AuMemory::MemoryViewStreamWrite;
#if defined(AURORA_RUNTIME_BAD_PLATFORM_FORCE_FUTEX_MUTEX_SEMAPHORE_IN_CLIENT)
using AuMutex = AuThreading::Waitables::FutexWaitable;
using AuSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
#else
using AuMutex = AuThreadPrimitives::Mutex;
using AuSemaphore = AuThreadPrimitives::Semaphore;
#endif
using AuRenterableMutex = AuThreadPrimitives::CriticalSection;
using AuCriticalSection = AuThreadPrimitives::CriticalSection;
using AuRWRenterableLock = AuThreadPrimitives::RWRenterableLock;
using AuRWLock = AuThreadPrimitives::RWLock;
using AuCond = AuThreadPrimitives::ConditionVariable;
using AuConditionVariable = AuThreadPrimitives::ConditionVariable;
using AuCondition = AuThreadPrimitives::ConditionVariable;
using AuCondMutex = AuThreadPrimitives::ConditionMutex;
using AuSpinLock = AuThreadPrimitives::SpinLock;
using AuCondEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuFlexibleConditionVariable = AuThreadPrimitives::FlexibleConditionVariable;
using AuConditionEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuBinarySemaphore = AuThreadPrimitives::Event;
using AuEvent = AuThreadPrimitives::Event;
using AuFutexMutex = AuThreading::Waitables::FutexWaitable;
using AuFutexSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
using AuFutexCond = AuThreading::Waitables::FutexCondWaitable;
using AuFutexCondition = AuThreading::Waitables::FutexCondWaitable;
using AuFutexBarrier = AuThreading::Waitables::FutexBarrier;
using AuBarrier = AuThreading::Waitables::FutexBarrier;
using AuInitOnce = AuThreading::InitOnce;
using AuInitOnceSmall = __audetail::InitOnceABI;
template<typename T, bool bIsStatic = false>
using AuTLSVariable = AuThreads::TLSVariable<T, bIsStatic>;
using AuIOHandle = AuIO::IOHandle;
using AuSharedIOHandle = AuSPtr<AuIO::IOHandle>;
static bool AuIsThreadRunning()
{
return !AuThreads::GetThread()->Exiting();
}
static inline void AuDebugBreak()
{
AuDebug::DebugBreak();
}

View File

@ -0,0 +1,285 @@
/***
Copyright (C) 2021-2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: RuntimeConfig.hpp
Date: 2023-1-12
Date: 2021-6-9
Author: Reece
***/
#pragma once
namespace Aurora
{
struct LocalLogInfo
{
bool bEnableLogging { true };
AuLog::DirectoryLogger defaultFileLogger
{
/* uMaxLogsOrZeroBeforeCompress */ 16, /* uMaxLogsOrZeroBeforeDelete */ 0,
/* uMaxCumulativeFileSizeInMiBOrZeroBeforeCompress*/ 0, /* uMaxCumulativeFileSizeInMiBOrZeroBeforeDelete */ 128 * 1024 * 1024,
0, 0
};
#if defined(AU_CFG_ID_SHIP)
bool bWriteLogsToUserDir { true }; // use user directory
#else
bool bWriteLogsToUserDir { false }; // use cwd
#endif
};
struct TelemetryConfigDoc
{
bool enabled { false };
};
struct TelemetryConfig
{
bool readModNameJsonConfig {};
TelemetryConfigDoc defaultConfig;
};
struct ConsoleConfig
{
/// Enables Aurora::Console::xxxStd functions; defer to enableStdXX for default logger behaviour
bool enableStdPassthrough {false};
/// Enables standard, debug, and GUI consoles
bool enableConsole {true};
/// Attempt to force a terminal emulator host under graphical subsystems
bool forceConsoleWindow {};
/// Attempt to force a GUI console under command line targets
bool forceToolKitWindow {};
/// In conjunction with enableStdPassthrough, Aurora::Console::ReadStd reads a binary stream
/// In conjunction with !enableStdPassthrough, enables stdin cmd processing, otherwise disables stdin input
bool enableStdIn {true};
/// In conjunction with enableStdPassthrough, enables Aurora::Console::WriteStd to write binary, otherwise enables the console logger
/// In conjunction with !enableStdPassthrough, enables stdout logging
bool enableStdOut {true};
/// Use WxWidgets when possible
bool enableWxWidgets {true};
/// Delegate stdout writes to loops -> recommended for servers
bool asyncWrite {true};
/// Async debug log
bool asyncVSLog {false};
/// Should stdout print the full date or a mere HH MM SS prefix?
bool bStdOutShortTime { false };
///
bool bStdOutUseLocalTime { true };
#if 1
/// FIO config
LocalLogInfo fio;
#endif
AuString titleBrand = "Aurora SDK Sample";
AuString supportPublic {"https://git.reece.sx/AuroraSupport/AuroraRuntime/issues"};
AuString supportInternal {"https://jira.reece.sx"};
bool consoleTTYHasPerAppHistory {true};
};
struct LoggerConfig
{
/// FIO config
LocalLogInfo fileConfiguration;
/// Socket config
// tbd
};
struct CryptoConfig
{
/// Defer to the rationales in the implementation
/// Update 2023: world war 3 hasnt happened yet
bool allowChineseCerts {false};
/// Defer to the rationales in the implementation
/// Update 2023: spoilers it had nothing to do with the 2022 russian trolling directly, but who didn't see it coming?
/// i dont care about politics; its just useful to divide the glow by factions.
bool allowRussianCerts {true};
};
struct AsyncConfig
{
bool bStartSchedularOnStartup { true }; // turn this off to make your application lighter-weight; turn this on for higher performance (+expensive) scheduling
bool bEnableLegacyTicks { false }; // turn this on to enable an async apps singleton threadpool to SysPump on worker id zero. Alternatively, use SetMainThreadForSysPumpScheduling once you have a thread pool and worker id.
AuUInt32 threadPoolDefaultStackSize { };
AuUInt32 dwSchedulerRateLimitMS { 2 }; //
AuUInt32 dwLegacyMainThreadSystemTickMS { 25 }; // nowadays this is primarily used to dispatch main-thread posted (AuConsole) commands
};
struct FIOConfig
{
AuOptional<AuString> optDefaultBrand = "Aurora SDK Sample";
bool bForceOverlappedUtilsToDelegatedThreadPool { false };
bool bIsIntranetTrusted {};
AuUInt32 uOverlappedUtilsThreadPoolSize { 2 }; // note: this does not relate to the overlapped aio apis
}; // these threads are only spawned as a fallback for AuFS::Overlapped*** apis
struct DebugConfig
{
/**
* @brief Precache/initialize symbols for printable stack traces under binaries not intended for shipping to consumers
*
* @warning true will result in artificially high commit charge under certain monitoring applications as application databases are
* precached into memory. these maps shouldn't be duplicated across processes (if the kernel plays nice). regardless,
* end users shouldn't see the hit. in the best case scenario, this serves as a quality of life upgrade for stage/debug
* binaries that want real time stack traces with file locations cached. noting that this isn't optional for stage win32
* builds with live exception traces with line info. in the future, debug tools should be able to parse telemetry dumps, though.
*/
bool bNonshipPrecachesSymbols { true };
/**
* @brief Activates the internal AddVectoredExceptionHandler handler. Might conflict with DRM and other debugging utilities
*/
bool bEnableWin32RootExceptionHandler { true };
/**
* @brief
*/
bool bEnableInjectedExceptionHandler { true };
/**
* @brief Raises a SysPanic in place of returning null over all allocators. This includes C++ containers which *should* be configured to use our overloaded allocators (compile ./Source/Alloc.cpp & link in with your application/library).
* If you're one of those people who don't like the idea of raising out of memory exceptions, and therefore compile without exceptions, this is an alternative this allows for exceptions to remain enabled for truly exceptional behaviour
* IE: we're fucked. Lets see if we can restart the root tick, at the risk of unaccounted for behaviour, because crashing over a STL parse exception or something stupid in that ballpark would be a really terrible **[end]user**-experience.
*/
bool bIsMemoryErrorFatal { false };
/**
* @brief
*/
bool bIsExceptionThrowFatal { false };
bool bSaveAllExceptionsAsMinidumpInBg { false };
bool bRaiseDebuggerToAllExceptionsInStageAndDbg { true };
bool bPrintExceptionStackTracesOut { true };
bool bIsApplicationClientSoftwareOnJitteryMemorySystem { false }; // enable me to enable padding from system out of memory conditions.
// the catch: usually this memory is reserved for exit callbacks, internal low memory conditions, error reporting, and the like.
//
// generally you should not exploit this without ** acknowledging this thread-local condition via AuDebug::[Add/Dec]MemoryCrunch. ** ( << tl;dr: recommended way of accessing this memory)
//
// setting this flag enables debug buffer memory to be used at any point during any threads execution - the moment mimalloc runs
// out of pre-reserved and system mappable memory. i wouldn't use this for anything except monolithic client/user-facing applications
// that are likely to run on low resource systems (low spec or heavy app), with untested/uncaught C++ allocations splattered everywhere.
// this could be VERY useful to end users who are running into `bIsMemoryErrorFatal` crashes.
AuUInt32 uDebugMemoryReserveSize { 3 * 1024 * 1024 }; /* nowdays: a single v8 isolate is low sub-tens MB of memory, executable file sizes are low mbs, image sizes are much larger. forget small low-footprint vms
of flex and bison yesteryear. 3MB given our heavyish standard footprint already is probably fine. how much memory do Java heap+JIT engines sink just to boot again?
this'll allow us to high tens of KBs of malicous strings, overhead for doing telemetry/(structured ???)logging, overhead to stack traces, module cache, etc.
i'm sure it'll also be enough to give back to the user, if need be.
@warning: 0 = 3 * 1024 * 1024
*/
bool bWin32VerifyTrustFailMissingAPI { true }; // just to not be annoying in the future
};
struct ThreadingConfig
{
// WARN: these values are not final
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar instruction before yielding into the kernel
AuUInt16 uSpinLoopPowerA { 128 }; // Nudgable spinloop power. This is our local userland niceness factor
// This is comparable to Win32's SetCriticalSectionSpinCount applied across every single AuThreadPrimitives try-lock and lock.
// Adjust this value to compensate for longer critical sections when context switching isn't preferrable.
AuUInt64 bEnableAggressiveScheduling : 1 { false };
AuUInt64 bEnableAgrSchedulingRatelimit : 1 { true };
AuUInt64 bPreferNt51XpMutexesOver8 : 1 { false };
AuUInt64 bPreferNt51XpCondvarsOver8 : 1 { false };
AuUInt64 bPreferNtCondvarModernWinSpin : 1 { false };
AuUInt64 bPreferNtCondvarOlderWinSpin : 1 { true };
AuUInt64 bPreferNtSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferNtMutexSpinTryLock : 1 { true };
AuUInt64 bPreferNtCondMutexSpinTryLock : 1 { false };
AuUInt64 bPreferLinuxSemaphoreSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxMutexSpinTryLock : 1 { true };
AuUInt64 bPreferLinuxCondMutexSpinTryLock : 1 { true };
#if 0
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { false };
#else
AuUInt64 bPreferEmulatedWakeOnAddress : 1 { !AuBuild::kIsNtDerived /*everybody else requires us to hit the kernel. */ };
#endif
AuUInt64 bPreferWaitOnAddressAlwaysSpin : 1 { false }; // ..., if emulated! if double-spinning under higher level locks, disable me.
AuUInt64 bPreferWaitOnAddressAlwaysSpinNative : 1 { !AuBuild::kIsNtDerived }; // ..., if not emulated! noting that most kernels and user-schedulers will spin for you
AuUInt64 bPreferRWLockReadLockSpin : 1 { true };
AuUInt64 bUWPNanosecondEmulationCheckFirst : 1 { false };
AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 };
AuUInt64 bForceEnableAdaptiveSpin : 1 { false }; // ||
AuUInt64 bPreferEnableAdaptiveSpin : 1 { true }; // .
AuUInt64 bPreferLinuxAdaptiveSpin : 1 { true }; // (&&)
AuUInt64 bPreferOldWin32AdaptiveSpin : 1 { false }; // (&&)
AuUInt64 bPreferNewWin32AdaptiveSpin : 1 { true }; // (&&)
AuUInt64 uAdaptiveSpinCUCnt0 : 4 { 0 } ;
AuUInt64 uAdaptiveSpinCUCnt4 : 4 { 2 };
AuUInt64 uAdaptiveSpinCUCnt8 : 4 { 2 };
AuUInt64 uAdaptiveSpinCUCnt16 : 4 { 4 };
AuUInt64 bPreferFutexRWLock : 1 { true };
AuUInt64 bWinXpThrough7BlazeOptimizerPower : 12 { 300 }; // dont worry about it. we dont care about old portables. lets try to make older win32 targets tweak the scheduling in our favor a bit.
AuUInt64 bPreferLinuxPrimitivesFutexNoSpin : 1 { false };
AuUInt64 bPreferUnixPrimitivesNoSpin : 1 { false };
AuUInt64 bAlwaysRWLockWriteBiasOnReadLock : 1 { false };
AuUInt64 bEnableRWLockWriteBiasOnReadLock : 1 { true };
AuUInt64 bPreferFutexEvent : 1 { true };
};
struct DummyConfig
{
};
struct LinuxConfig
{
bool bFIODisableBatching { false };
bool bIOLinuxHasProcIpcPerms { false };
AuUInt8 uSignalTerminate { 27 };
AuUInt8 uSignalGAIOWorkerThreadDone { 28 };
};
struct ProcessConfig
{
bool bAlwaysPreloadEntireClassPath { false };
bool bForcePreload { false };
bool bEnablePreload { true };
};
struct IOConfig
{
AuUInt32 uProtocolStackDefaultBufferSize { 64 * 1024 };
};
struct Win32Config
{
bool bProcessCheckWinLdrForModNameFirst { true };
};
struct RuntimeStartInfo
{
ConsoleConfig console;
AuAlignTo<512, CryptoConfig> crypto;
AuAlignTo<512, TelemetryConfig> telemetry;
AuAlignTo<32, AsyncConfig> async;
AuAlignTo<32, FIOConfig> fio;
AuAlignTo<64, DebugConfig> debug;
AuAlignTo<32, ThreadingConfig> threadingConfig;
AuAlignTo<32, LinuxConfig> linuxConfig;
AuAlignTo<32, Win32Config> win32Config;
AuAlignTo<32, ProcessConfig> processConfig;
AuAlignTo<32, IOConfig> ioConfig;
AuAlignTo<32, DummyConfig> padding;
};
}