eliminate synchronous per-thread string map building, just do it as-needed on each thread;

This commit is contained in:
Ryan Fleury
2024-03-04 11:53:12 -08:00
parent 4d6860b3a1
commit 091269b1d8
3 changed files with 16 additions and 12 deletions
+1 -2
View File
@@ -1227,7 +1227,6 @@ rdim_bake_string_chunk_list_push(RDIM_Arena *arena, RDIM_BakeStringChunkList *li
list->chunk_count += 1;
}
RDIM_BakeString *s = &n->v[n->count];
s->chunk = n;
n->count += 1;
list->total_count += 1;
return s;
@@ -1691,7 +1690,7 @@ rdim_bake_name_map_push(RDIM_Arena *arena, RDIM_BakeNameMap *map, RDIM_String8 s
if(node == 0)
{
node = rdim_push_array(arena, RDIM_BakeNameMapNode, 1);
node->string = rdim_str8_copy(arena, string);
node->string = string;
RDIM_SLLStackPush_N(map->slots[slot_idx], node, slot_next);
RDIM_SLLQueuePush_N(map->first, map->last, node, order_next);
map->name_count += 1;
-1
View File
@@ -836,7 +836,6 @@ struct RDIM_BakeSectionList
typedef struct RDIM_BakeString RDIM_BakeString;
struct RDIM_BakeString
{
struct RDIM_BakeStringChunkNode *chunk;
RDI_U64 hash;
RDIM_String8 string;
};
+15 -9
View File
@@ -3473,9 +3473,12 @@ p2r_convert(Arena *arena, P2R_User2Convert *in)
//- rjf: bake string map building
#define p2r_make_string_map_if_needed() do {if(in->maps[thread_idx] == 0) ProfScope("make map") {in->maps[thread_idx] = rdim_bake_string_map_loose_make(arena, in->top);}} while(0)
internal TS_TASK_FUNCTION_DEF(p2r_bake_src_files_strings_task__entry_point)
{
P2R_BakeSrcFilesStringsIn *in = (P2R_BakeSrcFilesStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake src file strings") rdim_bake_string_map_loose_push_src_files(arena, in->top, in->maps[thread_idx], in->list);
return 0;
}
@@ -3483,6 +3486,7 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_src_files_strings_task__entry_point)
internal TS_TASK_FUNCTION_DEF(p2r_bake_units_strings_task__entry_point)
{
P2R_BakeUnitsStringsIn *in = (P2R_BakeUnitsStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake unit strings") rdim_bake_string_map_loose_push_units(arena, in->top, in->maps[thread_idx], in->list);
return 0;
}
@@ -3490,6 +3494,7 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_units_strings_task__entry_point)
internal TS_TASK_FUNCTION_DEF(p2r_bake_types_strings_task__entry_point)
{
P2R_BakeTypesStringsIn *in = (P2R_BakeTypesStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake type strings")
{
for(P2R_BakeTypesStringsInNode *n = in->first; n != 0; n = n->next)
@@ -3503,6 +3508,7 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_types_strings_task__entry_point)
internal TS_TASK_FUNCTION_DEF(p2r_bake_udts_strings_task__entry_point)
{
P2R_BakeUDTsStringsIn *in = (P2R_BakeUDTsStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake udt strings")
{
for(P2R_BakeUDTsStringsInNode *n = in->first; n != 0; n = n->next)
@@ -3516,6 +3522,7 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_udts_strings_task__entry_point)
internal TS_TASK_FUNCTION_DEF(p2r_bake_symbols_strings_task__entry_point)
{
P2R_BakeSymbolsStringsIn *in = (P2R_BakeSymbolsStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake symbol strings")
{
for(P2R_BakeSymbolsStringsInNode *n = in->first; n != 0; n = n->next)
@@ -3529,6 +3536,7 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_symbols_strings_task__entry_point)
internal TS_TASK_FUNCTION_DEF(p2r_bake_scopes_strings_task__entry_point)
{
P2R_BakeScopesStringsIn *in = (P2R_BakeScopesStringsIn *)p;
p2r_make_string_map_if_needed();
ProfScope("bake scope strings")
{
for(P2R_BakeScopesStringsInNode *n = in->first; n != 0; n = n->next)
@@ -3539,6 +3547,8 @@ internal TS_TASK_FUNCTION_DEF(p2r_bake_scopes_strings_task__entry_point)
return 0;
}
#undef p2r_make_string_map_if_needed
//- rjf: bake string map joining
internal TS_TASK_FUNCTION_DEF(p2r_bake_string_map_join_task__entry_point)
@@ -3772,17 +3782,8 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
params->thread_variables.total_count*1 +
params->types.total_count/2)};
RDIM_BakeStringMapLoose **bake_string_maps__in_progress = push_array(scratch.arena, RDIM_BakeStringMapLoose *, ts_thread_count());
for(U64 idx = 0; idx < ts_thread_count(); idx += 1)
{
bake_string_maps__in_progress[idx] = rdim_bake_string_map_loose_make(arena, &bake_string_map_topology);
}
TS_TicketList bake_string_map_build_tickets = {0};
{
// rjf: basics
rdim_bake_string_map_loose_push_top_level_info(arena, &bake_string_map_topology, bake_string_maps__in_progress[0], &params->top_level_info);
rdim_bake_string_map_loose_push_binary_sections(arena, &bake_string_map_topology, bake_string_maps__in_progress[0], &params->binary_sections);
rdim_bake_string_map_loose_push_path_tree(arena, &bake_string_map_topology, bake_string_maps__in_progress[0], path_tree);
// rjf: src files
ProfScope("kick off src files string map build task")
{
@@ -3944,6 +3945,11 @@ p2r_bake(Arena *arena, P2R_Convert2Bake *in)
{
ts_join(task_tickets[task_idx], max_U64);
}
// rjf: insert small top-level stuff
rdim_bake_string_map_loose_push_top_level_info(arena, &bake_string_map_topology, unsorted_bake_string_map, &params->top_level_info);
rdim_bake_string_map_loose_push_binary_sections(arena, &bake_string_map_topology, unsorted_bake_string_map, &params->binary_sections);
rdim_bake_string_map_loose_push_path_tree(arena, &bake_string_map_topology, unsorted_bake_string_map, path_tree);
}
//- rjf: kick off string map sorting tasks