thin out needed entities for call stack build; fix unnecessary re-loops on async threads

This commit is contained in:
Ryan Fleury
2025-09-25 17:07:02 -07:00
parent 88eddce324
commit 9ad7361cb9
2 changed files with 36 additions and 24 deletions
+4
View File
@@ -524,6 +524,7 @@ ac_async_tick(void)
//- rjf: cancelled early, unfinished tasks? -> defer to next tick //- rjf: cancelled early, unfinished tasks? -> defer to next tick
if(lane_idx() == 0 && task_idx > 0) if(lane_idx() == 0 && task_idx > 0)
{ {
B32 need_another_try = (done_wide_count < task->wide_count || done_thin_count < task->thin_count);
AC_RequestBatch *batch = &ac_shared->req_batches[task_idx]; AC_RequestBatch *batch = &ac_shared->req_batches[task_idx];
MutexScope(batch->mutex) MutexScope(batch->mutex)
{ {
@@ -549,8 +550,11 @@ ac_async_tick(void)
n->v.key = str8_copy(batch->arena, n->v.key); n->v.key = str8_copy(batch->arena, n->v.key);
} }
} }
if(need_another_try)
{
ins_atomic_u32_eval_assign(&async_loop_again, 1); ins_atomic_u32_eval_assign(&async_loop_again, 1);
} }
}
lane_sync(); lane_sync();
} }
lane_sync(); lane_sync();
+9 -1
View File
@@ -7663,8 +7663,14 @@ ctrl_call_stack_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *r
{ {
rec = ctrl_entity_rec_depth_first_pre(src_e, src_process); rec = ctrl_entity_rec_depth_first_pre(src_e, src_process);
// rjf: determine if we need this entity
B32 need_this_entity = (ctrl_handle_match(thread_handle, src_e->handle) || src_e->kind == CTRL_EntityKind_Module || src_e->kind == CTRL_EntityKind_Process);
// rjf: copy this entity // rjf: copy this entity
CTRL_Entity *dst_e = push_array(scratch.arena, CTRL_Entity, 1); CTRL_Entity *dst_e = &ctrl_entity_nil;
if(need_this_entity)
{
dst_e = push_array(scratch.arena, CTRL_Entity, 1);
{ {
dst_e->first = dst_e->last = dst_e->next = dst_e->prev = &ctrl_entity_nil; dst_e->first = dst_e->last = dst_e->next = dst_e->prev = &ctrl_entity_nil;
dst_e->parent = dst_parent; dst_e->parent = dst_parent;
@@ -7689,8 +7695,10 @@ ctrl_call_stack_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *r
{ {
DLLPushBack_NPZ(&ctrl_entity_nil, dst_parent->first, dst_parent->last, dst_e, next, prev); DLLPushBack_NPZ(&ctrl_entity_nil, dst_parent->first, dst_parent->last, dst_e, next, prev);
} }
}
// rjf: insert into hash map // rjf: insert into hash map
if(dst_e != &ctrl_entity_nil)
{ {
U64 hash = ctrl_hash_from_handle(dst_e->handle); U64 hash = ctrl_hash_from_handle(dst_e->handle);
U64 slot_idx = hash%dst_ctx->hash_slots_count; U64 slot_idx = hash%dst_ctx->hash_slots_count;