speed up symbol patching

This commit is contained in:
Nikita Smith
2025-09-22 10:06:21 -07:00
parent 42999bea63
commit 3d7afb58fa
2 changed files with 32 additions and 27 deletions
+8 -4
View File
@@ -180,7 +180,6 @@ lnk_setup_pch(Arena *arena, U64 obj_count, LNK_Obj **obj_arr, CV_DebugT *debug_t
String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp.obj_name, work_dir); String8 obj_path = path_absolute_dst_from_relative_dst_src(scratch.arena, precomp.obj_name, work_dir);
// map obj name in LF_PRECOMP to obj index // map obj name in LF_PRECOMP to obj index
U64 debug_p_obj_idx = max_U64; U64 debug_p_obj_idx = max_U64;
if (!hash_table_search_path_u64(debug_p_ht, obj_path, &debug_p_obj_idx)) { if (!hash_table_search_path_u64(debug_p_ht, obj_path, &debug_p_obj_idx)) {
@@ -1981,10 +1980,12 @@ lnk_assign_type_indices(TP_Context *tp, LNK_LeafBucketArray bucket_arr, CV_TypeI
internal internal
THREAD_POOL_TASK_FUNC(lnk_patch_symbols_task) THREAD_POOL_TASK_FUNC(lnk_patch_symbols_task)
{ {
ProfBeginFunction();
LNK_PatchSymbolTypesTask *task = raw_task; LNK_PatchSymbolTypesTask *task = raw_task;
Arena *fixed_arena = task->arena_arr[worker_id]; Arena *fixed_arena = task->arena_arr[task_id];
LNK_CodeViewSymbolsInput symbol_input = task->input->symbol_inputs[task_id];
for EachInRange(symbol_input_idx, task->ranges[task_id]) {
LNK_CodeViewSymbolsInput symbol_input = task->input->symbol_inputs[symbol_input_idx];
LNK_LeafLocType loc_type = lnk_loc_type_from_obj_idx(task->input, symbol_input.obj_idx); LNK_LeafLocType loc_type = lnk_loc_type_from_obj_idx(task->input, symbol_input.obj_idx);
U64 loc_idx = lnk_loc_idx_from_obj_idx(task->input, symbol_input.obj_idx); U64 loc_idx = lnk_loc_idx_from_obj_idx(task->input, symbol_input.obj_idx);
@@ -2015,6 +2016,8 @@ THREAD_POOL_TASK_FUNC(lnk_patch_symbols_task)
temp_end(temp); temp_end(temp);
} }
} }
ProfEnd();
}
internal void internal void
lnk_patch_symbols(TP_Context *tp, lnk_patch_symbols(TP_Context *tp,
@@ -2028,11 +2031,12 @@ lnk_patch_symbols(TP_Context *tp,
U64 max_ti_list_size = sizeof(CV_TypeIndexInfo) * (max_U16 / sizeof(CV_TypeIndex)); U64 max_ti_list_size = sizeof(CV_TypeIndexInfo) * (max_U16 / sizeof(CV_TypeIndex));
LNK_PatchSymbolTypesTask task = {0}; LNK_PatchSymbolTypesTask task = {0};
task.ranges = tp_divide_work(scratch.arena, input->total_symbol_input_count, tp->worker_count);
task.input = input; task.input = input;
task.hashes = hashes; task.hashes = hashes;
task.leaf_ht_arr = leaf_ht_arr; task.leaf_ht_arr = leaf_ht_arr;
task.arena_arr = alloc_fixed_size_arena_array(scratch.arena, tp->worker_count, max_ti_list_size, max_ti_list_size); task.arena_arr = alloc_fixed_size_arena_array(scratch.arena, tp->worker_count, max_ti_list_size, max_ti_list_size);
tp_for_parallel(tp, 0, input->total_symbol_input_count, lnk_patch_symbols_task, &task); tp_for_parallel(tp, 0, tp->worker_count, lnk_patch_symbols_task, &task);
scratch_end(scratch); scratch_end(scratch);
ProfEnd(); ProfEnd();
+1
View File
@@ -236,6 +236,7 @@ typedef struct
typedef struct typedef struct
{ {
Rng1U64 *ranges;
LNK_CodeViewInput *input; LNK_CodeViewInput *input;
LNK_LeafHashes *hashes; LNK_LeafHashes *hashes;
LNK_LeafHashTable *leaf_ht_arr; LNK_LeafHashTable *leaf_ht_arr;