diff --git a/build.bat b/build.bat index 284ba6e0..82a27b43 100644 --- a/build.bat +++ b/build.bat @@ -123,6 +123,7 @@ if "%rdi_breakpad_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_br if "%tester%"=="1" set didbuild=1 && %compile% ..\src\tester\tester_main.c %compile_link% %out%tester.exe || exit /b 1 if "%ryan_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe || exit /b 1 if "%textperf%"=="1" set didbuild=1 && %compile% ..\src\scratch\textperf.c %compile_link% %out%textperf.exe || exit /b 1 +if "%convertperf%"=="1" set didbuild=1 && %compile% ..\src\scratch\convertperf.c %compile_link% %out%convertperf.exe || exit /b 1 if "%parse_inline_sites%"=="1" set didbuild=1 && %compile% ..\src\scratch\parse_inline_sites.c %compile_link% %out%parse_inline_sites.exe || exit /b 1 if "%mule_main%"=="1" set didbuild=1 && del vc*.pdb mule*.pdb && %compile_release% %only_compile% ..\src\mule\mule_inline.cpp && %compile_release% %only_compile% ..\src\mule\mule_o2.cpp && %compile_debug% %EHsc% ..\src\mule\mule_main.cpp ..\src\mule\mule_c.c mule_inline.obj mule_o2.obj %compile_link% %no_aslr% %out%mule_main.exe || exit /b 1 if "%mule_module%"=="1" set didbuild=1 && %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll || exit /b 1 diff --git a/src/async/async.c b/src/async/async.c index fa2a046d..9e8cda09 100644 --- a/src/async/async.c +++ b/src/async/async.c @@ -5,7 +5,7 @@ //~ rjf: Top-Level Layer Initialization internal void -async_init(void) +async_init(CmdLine *cmdline) { Arena *arena = arena_alloc(); async_shared = push_array(arena, ASYNC_Shared, 1); @@ -20,8 +20,12 @@ async_init(void) } async_shared->ring_mutex = os_mutex_alloc(); async_shared->ring_cv = os_condition_variable_alloc(); - async_shared->work_threads_count = Max(1, os_get_system_info()->logical_processor_count-1); - async_shared->work_threads = push_array(arena, OS_Handle, async_shared->work_threads_count); + String8 work_thread_count_string = cmd_line_string(cmdline, str8_lit("work_threads_count")); + if(work_thread_count_string.size == 0 || !try_u64_from_str8_c_rules(work_thread_count_string, &async_shared->work_threads_count)) + { + async_shared->work_threads_count = Max(1, os_get_system_info()->logical_processor_count-1); + } + async_shared->work_threads = push_array(arena, OS_Handle, async_shared->work_threads_count); for EachIndex(idx, async_shared->work_threads_count) { async_shared->work_threads[idx] = os_thread_launch(async_work_thread__entry_point, (void *)idx, 0); diff --git a/src/async/async.h b/src/async/async.h index 4da20144..f793f3d1 100644 --- a/src/async/async.h +++ b/src/async/async.h @@ -108,7 +108,7 @@ global ASYNC_Shared *async_shared = 0; //////////////////////////////// //~ rjf: Top-Level Layer Initialization -internal void async_init(void); +internal void async_init(CmdLine *cmdline); //////////////////////////////// //~ rjf: Top-Level Accessors diff --git a/src/base/base_entry_point.c b/src/base/base_entry_point.c index f7d37f4a..21bbc363 100644 --- a/src/base/base_entry_point.c +++ b/src/base/base_entry_point.c @@ -34,7 +34,7 @@ main_thread_base_entry_point(int arguments_count, char **arguments) //- rjf: initialize all included layers #if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL) - async_init(); + async_init(&cmdline); #endif #if defined(RDI_FROM_PDB_H) && !defined(P2R_INIT_MANUAL) p2r_init(); diff --git a/src/pdb/pdb_parse.c b/src/pdb/pdb_parse.c index 1c2d6b78..e6c42699 100644 --- a/src/pdb/pdb_parse.c +++ b/src/pdb/pdb_parse.c @@ -166,7 +166,7 @@ pdb_strtbl_from_data(Arena *arena, String8 data){ header = (PDB_StringTableHeader *)data.str; } - PDB_Strtbl *result = 0; + PDB_Strtbl *result = push_array(arena, PDB_Strtbl, 1); if (header != 0 && header->magic == PDB_StringTableHeader_MAGIC && header->version == 1){ U32 strblock_size_off = sizeof(*header); U32 strblock_size = 0; @@ -185,7 +185,6 @@ pdb_strtbl_from_data(Arena *arena, String8 data){ U32 bucket_array_size = bucket_count*sizeof(PDB_StringIndex); if (bucket_array_off + bucket_array_size <= data.size){ - result = push_array(arena, PDB_Strtbl, 1); result->data = data; result->bucket_count = bucket_count; result->strblock_min = strblock_off; diff --git a/src/scratch/convertperf.c b/src/scratch/convertperf.c new file mode 100644 index 00000000..d15901b2 --- /dev/null +++ b/src/scratch/convertperf.c @@ -0,0 +1,80 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//////////////////////////////// +//~ rjf: Build Options + +#define BUILD_TITLE "convertperf" + +//////////////////////////////// +//~ rjf: Includes + +//- rjf: [lib] +#include "third_party/rad_lzb_simple/rad_lzb_simple.h" +#include "third_party/rad_lzb_simple/rad_lzb_simple.c" + +//- rjf: [h] +#include "base/base_inc.h" +#include "os/os_inc.h" +#include "path/path.h" +#include "async/async.h" +#include "rdi_format/rdi_format_local.h" +#include "dbgi/dbgi.h" + +//- rjf: [c] +#include "base/base_inc.c" +#include "os/os_inc.c" +#include "path/path.c" +#include "async/async.c" +#include "rdi_format/rdi_format_local.c" +#include "dbgi/dbgi.c" + +//////////////////////////////// +//~ rjf: Entry Points + +internal void +entry_point(CmdLine *cmdline) +{ + Arena *arena = arena_alloc(); + String8 list_path = str8_list_first(&cmdline->inputs); + String8 list_data = os_data_from_file_path(arena, list_path); + U8 splits[] = {'\n'}; + String8List lines = str8_split(arena, list_data, splits, ArrayCount(splits), 0); + OS_HandleList processes = {0}; + String8Node *processes_first_path_n = 0; + + U64 limit = 32; + U64 idx = 0; + for(String8Node *n = lines.first; n != 0; n = n->next) + { + String8 dll_path = n->string; + ProfScope("kick off %.*s", str8_varg(dll_path)) + { + String8 dll_path_no_ext = str8_chop_last_dot(dll_path); + String8 dll_name = str8_skip_last_slash(dll_path_no_ext); + String8 pdb_path = push_str8f(arena, "%S.pdb", dll_path_no_ext); + String8 rdi_path = push_str8f(arena, "dump/%S.rdi", dll_name); + OS_Handle handle = os_cmd_line_launchf("raddbg --convert --work_threads_count:1 --pdb:%S --out:%S", pdb_path, rdi_path); + os_handle_list_push(arena, &processes, handle); + if(processes_first_path_n == 0) + { + processes_first_path_n = n; + } + idx += 1; + } + if(idx >= limit) + { + String8Node *line_n = processes_first_path_n; + for(OS_HandleNode *n = processes.first; n != 0; n = n->next, line_n = line_n->next) + { + ProfScope("join %.*s", str8_varg(line_n->string)) + { + os_process_join(n->v, max_U64); + } + } + idx = 0; + MemoryZeroStruct(&processes); + processes_first_path_n = 0; + } + } +} diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 851de265..532ed66f 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1782,7 +1782,6 @@ ui_layout_enforce_constraints__in_place_rec(UI_Box *root, Axis2 axis) } } } - } //- rjf: fixup upwards-relative sizes