From b1c5b308c0a9b37852116da3d54c7efadcc432f0 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Tue, 14 Jan 2025 10:42:14 -0800 Subject: [PATCH] collect inline site name string --- src/lib_rdi_make/rdi_make.c | 9 +++++++ src/lib_rdi_make/rdi_make.h | 2 ++ src/rdi_from_pdb/rdi_from_pdb.c | 48 +++++++++++++++++++++++++++++++++ src/rdi_from_pdb/rdi_from_pdb.h | 17 ++++++++++++ 4 files changed, 76 insertions(+) diff --git a/src/lib_rdi_make/rdi_make.c b/src/lib_rdi_make/rdi_make.c index ddfd77e62..3f37b9f5b 100644 --- a/src/lib_rdi_make/rdi_make.c +++ b/src/lib_rdi_make/rdi_make.c @@ -1968,6 +1968,15 @@ rdim_bake_string_map_loose_push_symbol_slice(RDIM_Arena *arena, RDIM_BakeStringM } } +RDI_PROC void +rdim_bake_string_map_loose_push_inline_site_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_InlineSite *v, RDI_U64 count) +{ + for(RDI_U64 idx = 0; idx < count; idx += 1) + { + rdim_bake_string_map_loose_insert(arena, top, map, 4, v[idx].name); + } +} + RDI_PROC void rdim_bake_string_map_loose_push_scope_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Scope *v, RDI_U64 count) { diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index 0a8e7d9b7..47ff5ade5 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -1471,6 +1471,8 @@ RDI_PROC void rdim_bake_string_map_loose_push_unit_slice(RDIM_Arena *arena, RDIM RDI_PROC void rdim_bake_string_map_loose_push_type_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Type *v, RDI_U64 count); RDI_PROC void rdim_bake_string_map_loose_push_udt_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDT *v, RDI_U64 count); RDI_PROC void rdim_bake_string_map_loose_push_symbol_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Symbol *v, RDI_U64 count); +RDI_PROC void rdim_bake_string_map_loose_push_inline_site_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_InlineSite *v, RDI_U64 count); + RDI_PROC void rdim_bake_string_map_loose_push_scope_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Scope *v, RDI_U64 count); //- rjf: list-granularity bake string gathering passes diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index efdd582f9..078740da4 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -4052,6 +4052,23 @@ ASYNC_WORK_DEF(p2r_bake_symbols_strings_work) return 0; } +ASYNC_WORK_DEF(p2r_bake_inline_site_strings_work) +{ + ProfBeginFunction(); + Arena *arena = p2r_state->work_thread_arenas[thread_idx]; + P2R_BakeInlineSiteStringsIn *in = input; + p2r_make_string_map_if_needed(); + ProfScope("bake inline site strings"); + { + for(P2R_BakeInlineSiteStringsInNode *n = in->first; n != 0; n = n->next) + { + rdim_bake_string_map_loose_push_inline_site_slice(arena, in->top, in->maps[thread_idx], n->v, n->count); + } + } + ProfEnd(); + return 0; +} + ASYNC_WORK_DEF(p2r_bake_scopes_strings_work) { ProfBeginFunction(); @@ -4518,6 +4535,37 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in) } } } + + ProfScope("kick off inline site string map build task") + { + U64 items_per_task = 4096; + U64 num_tasks = CeilIntegerDiv(in_params->inline_sites.total_count, items_per_task); + RDIM_InlineSiteChunkNode *chunk = in_params->inline_sites.first; + U64 chunk_off = 0; + for(U64 task_idx = 0; task_idx < num_tasks; task_idx += 1) + { + P2R_BakeInlineSiteStringsIn *in = push_array(scratch.arena, P2R_BakeInlineSiteStringsIn, 1); + in->top = &bake_string_map_topology; + in->maps = bake_string_maps__in_progress; + U64 items_left = items_per_task; + for(;chunk != 0 && items_left > 0;) + { + U64 items_in_this_chunk = Min(items_per_task, chunk->count-chunk_off); + P2R_BakeInlineSiteStringsInNode *n = push_array(scratch.arena, P2R_BakeInlineSiteStringsInNode, 1); + SLLQueuePush(in->first, in->last, n); + n->v = chunk->v + chunk_off; + n->count = items_in_this_chunk; + chunk_off += items_in_this_chunk; + items_left -= items_in_this_chunk; + if(chunk_off >= chunk->count) + { + chunk = chunk->next; + chunk_off = 0; + } + } + async_task_list_push(scratch.arena, &bake_string_map_build_tasks, async_task_launch(scratch.arena, p2r_bake_inline_site_strings_work, .input = in)); + } + } // rjf: scope chunks ProfScope("kick off scope chunks string map build tasks") diff --git a/src/rdi_from_pdb/rdi_from_pdb.h b/src/rdi_from_pdb/rdi_from_pdb.h index 7535d4504..ced21a66d 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.h +++ b/src/rdi_from_pdb/rdi_from_pdb.h @@ -353,6 +353,23 @@ struct P2R_BakeSymbolsStringsIn P2R_BakeSymbolsStringsInNode *last; }; +typedef struct P2R_BakeInlineSiteStringsInNode P2R_BakeInlineSiteStringsInNode; +struct P2R_BakeInlineSiteStringsInNode +{ + P2R_BakeInlineSiteStringsInNode *next; + RDIM_InlineSite *v; + RDI_U64 count; +}; + +typedef struct P2R_BakeInlineSiteStringsIn P2R_BakeInlineSiteStringsIn; +struct P2R_BakeInlineSiteStringsIn +{ + RDIM_BakeStringMapTopology *top; + RDIM_BakeStringMapLoose **maps; + P2R_BakeInlineSiteStringsInNode *first; + P2R_BakeInlineSiteStringsInNode *last; +}; + typedef struct P2R_BakeScopesStringsInNode P2R_BakeScopesStringsInNode; struct P2R_BakeScopesStringsInNode {