Skip to content

Commit

Permalink
collect inline site name string
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaSmith057 committed Jan 14, 2025
1 parent 24efb57 commit b1c5b30
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib_rdi_make/rdi_make.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/lib_rdi_make/rdi_make.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions src/rdi_from_pdb/rdi_from_pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions src/rdi_from_pdb/rdi_from_pdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit b1c5b30

Please sign in to comment.