mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
replaced /RAD_IDLE_WORKERS with /RAD_SHARED_THREAD_POOL_MAX_WORKERS
This commit is contained in:
+1
-1
@@ -3190,7 +3190,7 @@ lnk_run(int argc, char **argv)
|
|||||||
|
|
||||||
LNK_Config *config = lnk_build_config(scratch.arena, argc, argv);
|
LNK_Config *config = lnk_build_config(scratch.arena, argc, argv);
|
||||||
|
|
||||||
TP_Context *tp = tp_alloc(scratch.arena, config->worker_count, config->shared_thread_pool_name);
|
TP_Context *tp = tp_alloc(scratch.arena, config->worker_count, config->max_worker_count, config->shared_thread_pool_name);
|
||||||
TP_Arena *tp_arena = tp_arena_alloc(tp);
|
TP_Arena *tp_arena = tp_arena_alloc(tp);
|
||||||
|
|
||||||
#if PROFILE_TELEMETRY
|
#if PROFILE_TELEMETRY
|
||||||
|
|||||||
+35
-16
@@ -138,7 +138,6 @@ global read_only struct
|
|||||||
{ LNK_CmdSwitch_Rad_EnvLib, "RAD_ENV_LIB", "[:NO]", "" },
|
{ LNK_CmdSwitch_Rad_EnvLib, "RAD_ENV_LIB", "[:NO]", "" },
|
||||||
{ LNK_CmdSwitch_Rad_Exe, "RAD_EXE", "[:NO]", "" },
|
{ LNK_CmdSwitch_Rad_Exe, "RAD_EXE", "[:NO]", "" },
|
||||||
{ LNK_CmdSwitch_Rad_Guid, "RAD_GUID", ":{IMAGEBLAKE3|XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXX}", "" },
|
{ LNK_CmdSwitch_Rad_Guid, "RAD_GUID", ":{IMAGEBLAKE3|XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXX}", "" },
|
||||||
{ LNK_CmdSwitch_Rad_IdleWorkers, "RAD_IDLE_WORKERS", ":#", "Number of workers to leave idle." },
|
|
||||||
{ LNK_CmdSwitch_Rad_LargePages, "RAD_LARGE_PAGES", "[:NO]", "Disabled by default on Windows." },
|
{ LNK_CmdSwitch_Rad_LargePages, "RAD_LARGE_PAGES", "[:NO]", "Disabled by default on Windows." },
|
||||||
{ LNK_CmdSwitch_Rad_LinkVer, "RAD_LINK_VER", ":##,##", "" },
|
{ LNK_CmdSwitch_Rad_LinkVer, "RAD_LINK_VER", ":##,##", "" },
|
||||||
{ LNK_CmdSwitch_Rad_Log, "RAD_LOG", ":{ALL,INPUT_OBJ,INPUT_LIB,IO,LINK_STATS,TIMERS}", "" },
|
{ LNK_CmdSwitch_Rad_Log, "RAD_LOG", ":{ALL,INPUT_OBJ,INPUT_LIB,IO,LINK_STATS,TIMERS}", "" },
|
||||||
@@ -151,6 +150,7 @@ global read_only struct
|
|||||||
{ LNK_CmdSwitch_Rad_PdbHashTypeNames, "RAD_PDB_HASH_TYPE_NAMES", ":{NONE|LENIENT|FULL}", "Replace type names in LF_STRUCTURE and LF_CLASS with hashes." },
|
{ LNK_CmdSwitch_Rad_PdbHashTypeNames, "RAD_PDB_HASH_TYPE_NAMES", ":{NONE|LENIENT|FULL}", "Replace type names in LF_STRUCTURE and LF_CLASS with hashes." },
|
||||||
{ LNK_CmdSwitch_Rad_SectVirtOff, "RAD_SECT_VIRT_OFF", ":#", "Set RVA where section data is placed in memory. For internal use only." },
|
{ LNK_CmdSwitch_Rad_SectVirtOff, "RAD_SECT_VIRT_OFF", ":#", "Set RVA where section data is placed in memory. For internal use only." },
|
||||||
{ LNK_CmdSwitch_Rad_SharedThreadPool, "RAD_SHARED_THREAD_POOL", "[:STRING]", "Default value \"" LNK_DEFAULT_THREAD_POOL_NAME "\"" },
|
{ LNK_CmdSwitch_Rad_SharedThreadPool, "RAD_SHARED_THREAD_POOL", "[:STRING]", "Default value \"" LNK_DEFAULT_THREAD_POOL_NAME "\"" },
|
||||||
|
{ LNK_CmdSwitch_Rad_SharedThreadPoolMaxWorkers, "RAD_SHARED_THREAD_POOL_MAX_WORKERS", ":#", "Sets maximum number of workers in a thread pool." },
|
||||||
{ LNK_CmdSwitch_Rad_SuppressError, "RAD_SUPPRESS_ERROR", ":#", "" },
|
{ LNK_CmdSwitch_Rad_SuppressError, "RAD_SUPPRESS_ERROR", ":#", "" },
|
||||||
{ LNK_CmdSwitch_Rad_SymbolTableCapDefined, "RAD_SYMBOL_TABLE_CAP_DEFINED", ":#", "Number of buckets allocated in the symbol table for defined symbols." },
|
{ LNK_CmdSwitch_Rad_SymbolTableCapDefined, "RAD_SYMBOL_TABLE_CAP_DEFINED", ":#", "Number of buckets allocated in the symbol table for defined symbols." },
|
||||||
{ LNK_CmdSwitch_Rad_SymbolTableCapInternal, "RAD_SYMBOL_TABLE_CAP_INTERNAL", ":#", "Number of buckets allocated in the symbol table for internal symbols." },
|
{ LNK_CmdSwitch_Rad_SymbolTableCapInternal, "RAD_SYMBOL_TABLE_CAP_INTERNAL", ":#", "Number of buckets allocated in the symbol table for internal symbols." },
|
||||||
@@ -159,7 +159,7 @@ global read_only struct
|
|||||||
{ LNK_CmdSwitch_Rad_TargetOs, "RAD_TARGET_OS", ":{WINDOWS,LINUX,MAC}" },
|
{ LNK_CmdSwitch_Rad_TargetOs, "RAD_TARGET_OS", ":{WINDOWS,LINUX,MAC}" },
|
||||||
{ LNK_CmdSwitch_Rad_TimeStamp, "RAD_TIME_STAMP", ":#", "Time stamp embeded in EXE and PDB." },
|
{ LNK_CmdSwitch_Rad_TimeStamp, "RAD_TIME_STAMP", ":#", "Time stamp embeded in EXE and PDB." },
|
||||||
{ LNK_CmdSwitch_Rad_Version, "RAD_VERSION", "", "Print version and exit." },
|
{ LNK_CmdSwitch_Rad_Version, "RAD_VERSION", "", "Print version and exit." },
|
||||||
{ LNK_CmdSwitch_Rad_Workers, "RAD_WORKERS", ":#", "Sets number of workers created in the pool. Number is capped at 1024." },
|
{ LNK_CmdSwitch_Rad_Workers, "RAD_WORKERS", ":#", "Sets number of workers created in the pool. Number is capped at 1024. When /RAD_SHARED_THREAD_POOL is specified this number cant exceed /RAD_SHARED_THREAD_POOL_MAX_WORKERS." },
|
||||||
|
|
||||||
{ LNK_CmdSwitch_Help, "HELP", "", "" },
|
{ LNK_CmdSwitch_Help, "HELP", "", "" },
|
||||||
{ LNK_CmdSwitch_Help, "?", "", "" },
|
{ LNK_CmdSwitch_Help, "?", "", "" },
|
||||||
@@ -494,6 +494,12 @@ lnk_do_debug_info(LNK_Config *config)
|
|||||||
return do_debug_info;
|
return do_debug_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal B32
|
||||||
|
lnk_is_thread_pool_shared(LNK_Config *config)
|
||||||
|
{
|
||||||
|
return config->shared_thread_pool_name.size > 0;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal B32
|
internal B32
|
||||||
@@ -1553,10 +1559,6 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LNK_CmdSwitch_Rad_IdleWorkers: {
|
|
||||||
lnk_cmd_switch_parse_u64(obj_path, lib_path, cmd_switch, value_strings, &config->idle_worker_count, 0);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case LNK_CmdSwitch_Rad_LargePages: {
|
case LNK_CmdSwitch_Rad_LargePages: {
|
||||||
if (value_strings.node_count == 0) {
|
if (value_strings.node_count == 0) {
|
||||||
OS_ProcessInfo *process_info = os_get_process_info();
|
OS_ProcessInfo *process_info = os_get_process_info();
|
||||||
@@ -1687,6 +1689,21 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case LNK_CmdSwitch_Rad_SharedThreadPoolMaxWorkers: {
|
||||||
|
OS_SystemInfo *sysinfo = os_get_system_info();
|
||||||
|
if (value_strings.node_count == 0) {
|
||||||
|
config->max_worker_count = sysinfo->logical_processor_count;
|
||||||
|
} else {
|
||||||
|
lnk_cmd_switch_parse_u64(obj_path, lib_path, cmd_switch, value_strings, &config->max_worker_count, 0);
|
||||||
|
if (config->max_worker_count == 0) {
|
||||||
|
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "number of workers must be greater than zero");
|
||||||
|
} else if (config->max_worker_count > sysinfo->logical_processor_count) {
|
||||||
|
lnk_error_cmd_switch(LNK_Warning_Cmdl, obj_path, lib_path, cmd_switch, "number of workers %llu exceeds processor count %llu", config->max_worker_count, sysinfo->logical_processor_count);
|
||||||
|
config->max_worker_count = sysinfo->logical_processor_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case LNK_CmdSwitch_Rad_SuppressError: {
|
case LNK_CmdSwitch_Rad_SuppressError: {
|
||||||
U64List error_code_list = {0};
|
U64List error_code_list = {0};
|
||||||
if (lnk_cmd_switch_parse_u64_list(scratch.arena, obj_path, lib_path, cmd_switch, value_strings, &error_code_list, 0)) {
|
if (lnk_cmd_switch_parse_u64_list(scratch.arena, obj_path, lib_path, cmd_switch, value_strings, &error_code_list, 0)) {
|
||||||
@@ -1804,6 +1821,11 @@ lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line)
|
|||||||
lnk_cmd_line_push_optionf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_SuppressError, "%u", LNK_Error_InvalidTypeIndex);
|
lnk_cmd_line_push_optionf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_SuppressError, "%u", LNK_Error_InvalidTypeIndex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set default max worker count
|
||||||
|
if (lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_Rad_SharedThreadPool)) {
|
||||||
|
lnk_cmd_line_push_optionf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_SharedThreadPoolMaxWorkers, "");
|
||||||
|
}
|
||||||
|
|
||||||
if (!lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_Rad_MtPath)) {
|
if (!lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_Rad_MtPath)) {
|
||||||
lnk_cmd_line_push_option_if_not_presentf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_MtPath, "%s", LNK_MANIFEST_MERGE_TOOL_NAME);
|
lnk_cmd_line_push_option_if_not_presentf(scratch.arena, &cmd_line, LNK_CmdSwitch_Rad_MtPath, "%s", LNK_MANIFEST_MERGE_TOOL_NAME);
|
||||||
}
|
}
|
||||||
@@ -1825,16 +1847,6 @@ lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line)
|
|||||||
lnk_apply_cmd_option_to_config(arena, config, cmd->string, cmd->value_strings, str8_zero(), str8_zero());
|
lnk_apply_cmd_option_to_config(arena, config, cmd->string, cmd->value_strings, str8_zero(), str8_zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply idle workers switch
|
|
||||||
if (config->idle_worker_count > 0) {
|
|
||||||
if (config->idle_worker_count < config->worker_count) {
|
|
||||||
U64 final_worker_count = config->worker_count - config->idle_worker_count;
|
|
||||||
config->worker_count = final_worker_count;
|
|
||||||
} else {
|
|
||||||
lnk_error_cmd_switch(LNK_Warning_Cmdl, str8_zero(), str8_zero(), LNK_CmdSwitch_Rad_IdleWorkers, "idle worker count %u exceeds total worker count %u", config->idle_worker_count, config->worker_count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// :manifest_input
|
// :manifest_input
|
||||||
if (lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_ManifestInput)) {
|
if (lnk_cmd_line_has_switch(cmd_line, LNK_CmdSwitch_ManifestInput)) {
|
||||||
if (config->manifest_opt == LNK_ManifestOpt_Embed) {
|
if (config->manifest_opt == LNK_ManifestOpt_Embed) {
|
||||||
@@ -1923,6 +1935,13 @@ lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lnk_is_thread_pool_shared(config)) {
|
||||||
|
if (config->worker_count > config->max_worker_count) {
|
||||||
|
config->worker_count = config->max_worker_count;
|
||||||
|
lnk_error_cmd_switch(LNK_Warning_Cmdl, str8_zero(), str8_zero(), LNK_CmdSwitch_Rad_Workers, "worker count %llu exceeds thread pool max worker count %llu; claping count to max", config->worker_count, config->max_worker_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set flags for /FIXED
|
// set flags for /FIXED
|
||||||
if (config->flags & LNK_ConfigFlag_Fixed) {
|
if (config->flags & LNK_ConfigFlag_Fixed) {
|
||||||
config->file_characteristics |= PE_ImageFileCharacteristic_STRIPPED;
|
config->file_characteristics |= PE_ImageFileCharacteristic_STRIPPED;
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ typedef enum
|
|||||||
LNK_CmdSwitch_Rad_EnvLib,
|
LNK_CmdSwitch_Rad_EnvLib,
|
||||||
LNK_CmdSwitch_Rad_Exe,
|
LNK_CmdSwitch_Rad_Exe,
|
||||||
LNK_CmdSwitch_Rad_Guid,
|
LNK_CmdSwitch_Rad_Guid,
|
||||||
LNK_CmdSwitch_Rad_IdleWorkers,
|
|
||||||
LNK_CmdSwitch_Rad_LargePages,
|
LNK_CmdSwitch_Rad_LargePages,
|
||||||
LNK_CmdSwitch_Rad_LinkVer,
|
LNK_CmdSwitch_Rad_LinkVer,
|
||||||
LNK_CmdSwitch_Rad_Log,
|
LNK_CmdSwitch_Rad_Log,
|
||||||
@@ -148,6 +147,7 @@ typedef enum
|
|||||||
LNK_CmdSwitch_Rad_PdbHashTypeNameLength,
|
LNK_CmdSwitch_Rad_PdbHashTypeNameLength,
|
||||||
LNK_CmdSwitch_Rad_SectVirtOff,
|
LNK_CmdSwitch_Rad_SectVirtOff,
|
||||||
LNK_CmdSwitch_Rad_SharedThreadPool,
|
LNK_CmdSwitch_Rad_SharedThreadPool,
|
||||||
|
LNK_CmdSwitch_Rad_SharedThreadPoolMaxWorkers,
|
||||||
LNK_CmdSwitch_Rad_SuppressError,
|
LNK_CmdSwitch_Rad_SuppressError,
|
||||||
LNK_CmdSwitch_Rad_SymbolTableCapDefined,
|
LNK_CmdSwitch_Rad_SymbolTableCapDefined,
|
||||||
LNK_CmdSwitch_Rad_SymbolTableCapInternal,
|
LNK_CmdSwitch_Rad_SymbolTableCapInternal,
|
||||||
@@ -312,7 +312,7 @@ typedef struct LNK_Config
|
|||||||
U64 page_size;
|
U64 page_size;
|
||||||
U64 pdb_page_size;
|
U64 pdb_page_size;
|
||||||
U64 worker_count;
|
U64 worker_count;
|
||||||
U64 idle_worker_count;
|
U64 max_worker_count;
|
||||||
String8 shared_thread_pool_name;
|
String8 shared_thread_pool_name;
|
||||||
U64 *function_pad_min;
|
U64 *function_pad_min;
|
||||||
U64 *manifest_resource_id;
|
U64 *manifest_resource_id;
|
||||||
@@ -529,6 +529,7 @@ internal Version lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem
|
|||||||
internal Version lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
|
internal Version lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
|
||||||
|
|
||||||
internal B32 lnk_do_debug_info (LNK_Config *config);
|
internal B32 lnk_do_debug_info (LNK_Config *config);
|
||||||
|
internal B32 lnk_is_thread_pool_shared(LNK_Config *config);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// Specialized Parsers
|
// Specialized Parsers
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ tp_worker_main_shared(void *raw_worker)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal TP_Context *
|
internal TP_Context *
|
||||||
tp_alloc(Arena *arena, U32 worker_count, String8 name)
|
tp_alloc(Arena *arena, U32 worker_count, U32 max_worker_count, String8 name)
|
||||||
{
|
{
|
||||||
ProfBeginDynamic("Alloc Thread Pool [Worker Count: %u]", worker_count);
|
ProfBeginDynamic("Alloc Thread Pool [Worker Count: %u]", worker_count);
|
||||||
AssertAlways(worker_count > 0);
|
AssertAlways(worker_count > 0);
|
||||||
@@ -71,7 +71,8 @@ tp_alloc(Arena *arena, U32 worker_count, String8 name)
|
|||||||
if (worker_count > 1) {
|
if (worker_count > 1) {
|
||||||
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
||||||
if (is_shared) {
|
if (is_shared) {
|
||||||
task_semaphore = os_semaphore_alloc(0, worker_count, name);
|
AssertAlways(worker_count <= max_worker_count);
|
||||||
|
task_semaphore = os_semaphore_alloc(0, max_worker_count, name);
|
||||||
exec_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
exec_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
||||||
} else {
|
} else {
|
||||||
task_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
task_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ typedef struct TP_Context
|
|||||||
S64 task_left;
|
S64 task_left;
|
||||||
} TP_Context;
|
} TP_Context;
|
||||||
|
|
||||||
internal TP_Context * tp_alloc(Arena *arena, U32 worker_count, String8 name);
|
internal TP_Context * tp_alloc(Arena *arena, U32 worker_count, U32 max_worker_count, String8 name);
|
||||||
internal void tp_release(TP_Context *pool);
|
internal void tp_release(TP_Context *pool);
|
||||||
internal TP_Arena * tp_arena_alloc(TP_Context *pool);
|
internal TP_Arena * tp_arena_alloc(TP_Context *pool);
|
||||||
internal void tp_arena_release(TP_Arena **arena_ptr);
|
internal void tp_arena_release(TP_Arena **arena_ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user